module-concat/spec/acceptance/concat_spec.rb

205 lines
5.7 KiB
Ruby
Raw Normal View History

require 'spec_helper_acceptance'
2013-08-08 17:44:31 +02:00
describe 'basic concat test' do
shared_examples 'successfully_applied' do |pp|
it 'applies the manifest twice with no stderr' do
2014-09-08 21:01:30 +02:00
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
2013-08-08 17:44:31 +02:00
end
describe file("#{default['puppetvardir']}/concat") do
2013-08-08 17:44:31 +02:00
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 755 }
end
describe file("#{default['puppetvardir']}/concat/bin") do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 755 }
end
describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do
it { should be_file }
it { should be_owned_by 'root' }
#it { should be_grouped_into 'root' }
it { should be_mode 755 }
2013-08-08 17:44:31 +02:00
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do
2013-08-08 17:44:31 +02:00
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 750 }
2013-08-08 17:44:31 +02:00
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do
2013-08-08 17:44:31 +02:00
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 750 }
2013-08-08 17:44:31 +02:00
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do
2013-08-08 17:44:31 +02:00
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 640 }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat.out") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 640 }
2013-08-08 17:44:31 +02:00
end
end
context 'owner/group root' do
2013-11-14 04:28:27 +01:00
pp = <<-EOS
2013-11-06 04:40:03 +01:00
concat { '/tmp/concat/file':
owner => 'root',
group => 'root',
mode => '0644',
}
concat::fragment { '1':
2013-11-06 04:40:03 +01:00
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
2013-11-06 04:40:03 +01:00
target => '/tmp/concat/file',
content => '2',
order => '02',
}
2013-11-14 04:28:27 +01:00
EOS
it_behaves_like 'successfully_applied', pp
2013-11-06 04:40:03 +01:00
describe file('/tmp/concat/file') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
it { should contain '1' }
it { should contain '2' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 640 }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 640 }
end
end
context 'owner/group non-root' do
before(:all) do
shell "groupadd -g 64444 bob"
shell "useradd -u 42 -g 64444 bob"
end
after(:all) do
shell "userdel bob"
end
pp="
2013-11-06 04:40:03 +01:00
concat { '/tmp/concat/file':
owner => 'bob',
group => 'bob',
mode => '0644',
}
concat::fragment { '1':
2013-11-06 04:40:03 +01:00
target => '/tmp/concat/file',
content => '1',
order => '01',
}
concat::fragment { '2':
2013-11-06 04:40:03 +01:00
target => '/tmp/concat/file',
content => '2',
order => '02',
}
"
2013-08-08 17:44:31 +02:00
it_behaves_like 'successfully_applied', pp
2013-11-06 04:40:03 +01:00
describe file('/tmp/concat/file') do
it { should be_file }
it { should be_owned_by 'bob' }
it { should be_grouped_into 'bob' }
it { should be_mode 644 }
it { should contain '1' }
it { should contain '2' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 640 }
it { should contain '1' }
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 640 }
it { should contain '2' }
end
2013-08-08 17:44:31 +02:00
end
context 'ensure' do
context 'works when set to present with path set' do
pp="
concat { 'file':
ensure => present,
path => '/tmp/concat/file',
mode => '0644',
}
concat::fragment { '1':
target => 'file',
content => '1',
order => '01',
}
"
it_behaves_like 'successfully_applied', pp
describe file('/tmp/concat/file') do
it { should be_file }
it { should be_mode 644 }
it { should contain '1' }
end
end
context 'works when set to absent with path set' do
pp="
concat { 'file':
ensure => absent,
path => '/tmp/concat/file',
mode => '0644',
}
concat::fragment { '1':
target => 'file',
content => '1',
order => '01',
}
"
# Can't used shared examples as this will always trigger the exec when
# absent is set.
it 'applies the manifest twice with no stderr' do
2014-09-08 21:01:30 +02:00
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_failures => true)
end
describe file('/tmp/concat/file') do
it { should_not be_file }
end
end
end
2013-08-08 17:44:31 +02:00
end