2013-11-13 19:15:10 +01:00
|
|
|
require 'spec_helper_system'
|
|
|
|
|
|
|
|
describe 'concat::fragment source lists ' do
|
|
|
|
context 'should create files containing first match only.' do
|
2013-11-14 04:28:27 +01:00
|
|
|
let(:file1_contents) { 'file1 contents' }
|
|
|
|
let(:file2_contents) { 'file2 contents' }
|
2013-11-13 23:23:30 +01:00
|
|
|
before(:all) do
|
2013-11-14 04:28:27 +01:00
|
|
|
|
2013-11-06 04:40:03 +01:00
|
|
|
shell("/bin/echo '#{file1_contents}' > /tmp/concat/file1")
|
|
|
|
shell("/bin/echo '#{file2_contents}' > /tmp/concat/file2")
|
2013-11-13 23:23:30 +01:00
|
|
|
end
|
2013-11-14 04:28:27 +01:00
|
|
|
|
|
|
|
pp = <<-EOS
|
2013-11-06 04:40:03 +01:00
|
|
|
concat { '/tmp/concat/result_file1':
|
2013-11-13 19:15:10 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
mode => '0644',
|
|
|
|
}
|
2013-11-06 04:40:03 +01:00
|
|
|
concat { '/tmp/concat/result_file2':
|
2013-11-13 19:15:10 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
mode => '0644',
|
|
|
|
}
|
2013-11-06 04:40:03 +01:00
|
|
|
concat { '/tmp/concat/result_file3':
|
2013-11-13 19:15:10 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '1':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/result_file1',
|
|
|
|
source => [ '/tmp/concat/file1', '/tmp/concat/file2' ],
|
2013-11-13 19:15:10 +01:00
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
concat::fragment { '2':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/result_file2',
|
|
|
|
source => [ '/tmp/concat/file2', '/tmp/concat/file1' ],
|
2013-11-13 19:15:10 +01:00
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
concat::fragment { '3':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/result_file3',
|
|
|
|
source => [ '/tmp/concat/file1', '/tmp/concat/file2' ],
|
2013-11-13 19:15:10 +01:00
|
|
|
order => '01',
|
|
|
|
}
|
2013-11-14 04:28:27 +01:00
|
|
|
EOS
|
|
|
|
|
2013-11-13 19:15:10 +01:00
|
|
|
context puppet_apply(pp) do
|
|
|
|
its(:stderr) { should be_empty }
|
|
|
|
its(:exit_code) { should_not == 1 }
|
|
|
|
its(:refresh) { should be_nil }
|
|
|
|
its(:stderr) { should be_empty }
|
|
|
|
its(:exit_code) { should be_zero }
|
|
|
|
end
|
2013-11-06 04:40:03 +01:00
|
|
|
describe file('/tmp/concat/result_file1') do
|
2013-11-13 19:15:10 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should contain file1_contents }
|
|
|
|
it { should_not contain file2_contents }
|
|
|
|
end
|
2013-11-06 04:40:03 +01:00
|
|
|
describe file('/tmp/concat/result_file2') do
|
2013-11-13 19:15:10 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should contain file2_contents }
|
|
|
|
it { should_not contain file1_contents }
|
|
|
|
end
|
2013-11-06 04:40:03 +01:00
|
|
|
describe file('/tmp/concat/result_file3') do
|
2013-11-13 19:15:10 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should contain file1_contents }
|
|
|
|
it { should_not contain file2_contents }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'should fail if no match on source.' do
|
2013-11-13 23:23:30 +01:00
|
|
|
before(:all) do
|
2013-11-06 04:40:03 +01:00
|
|
|
shell("/bin/rm /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither")
|
2013-11-13 23:23:30 +01:00
|
|
|
end
|
2013-11-14 04:28:27 +01:00
|
|
|
|
|
|
|
pp = <<-EOS
|
2013-11-06 04:40:03 +01:00
|
|
|
concat { '/tmp/concat/fail_no_source':
|
2013-11-13 19:15:10 +01:00
|
|
|
owner => root,
|
|
|
|
group => root,
|
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '1':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/fail_no_source',
|
|
|
|
source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ],
|
2013-11-13 19:15:10 +01:00
|
|
|
order => '01',
|
|
|
|
}
|
2013-11-14 04:28:27 +01:00
|
|
|
EOS
|
|
|
|
|
2013-11-13 19:15:10 +01:00
|
|
|
context puppet_apply(pp) do
|
|
|
|
its(:exit_code) { should_not be_zero }
|
2013-11-13 23:23:30 +01:00
|
|
|
its(:exit_code) { should_not == 1 }
|
2013-11-13 19:15:10 +01:00
|
|
|
its(:refresh) { should be_nil }
|
|
|
|
end
|
2013-11-06 04:40:03 +01:00
|
|
|
describe file('/tmp/concat/fail_no_source') do
|
2013-11-13 23:23:30 +01:00
|
|
|
#FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack.
|
|
|
|
it { should_not be_file }
|
|
|
|
it { should_not be_directory }
|
2013-11-13 19:15:10 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|