module-concat/spec/acceptance/concat_spec.rb
Morgan Haskel 5f17a26256 Merge branch '1.0.x' into test_merge
Conflicts:
	CHANGELOG.md
	Gemfile
	Modulefile
	README.markdown
	Rakefile
	files/concatfragments.sh
	manifests/setup.pp
	metadata.json
	spec/acceptance/backup_spec.rb
	spec/acceptance/concat_spec.rb
	spec/acceptance/empty_spec.rb
	spec/acceptance/fragment_source_spec.rb
	spec/acceptance/newline_spec.rb
	spec/acceptance/nodesets/centos-64-x64.yml
	spec/acceptance/nodesets/default.yml
	spec/acceptance/nodesets/fedora-18-x64.yml
	spec/acceptance/nodesets/ubuntu-server-10044-x64.yml
	spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
	spec/acceptance/order_spec.rb
	spec/acceptance/replace_spec.rb
	spec/acceptance/symbolic_name_spec.rb
	spec/acceptance/warn_spec.rb
	spec/spec_helper_acceptance.rb
2014-09-10 15:03:35 -04:00

185 lines
5.3 KiB
Ruby

require 'spec_helper_acceptance'
case fact('osfamily')
when 'AIX'
username = 'root'
groupname = 'system'
when 'Darwin'
username = 'root'
groupname = 'wheel'
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
else
username = 'root'
groupname = 'root'
end
describe 'basic concat test' do
basedir = default.tmpdir('concat')
shared_examples 'successfully_applied' do |pp|
it 'applies the manifest twice with no stderr' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("#{default['puppetvardir']}/concat") do
it { should be_directory }
it { should be_owned_by username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
should be_mode 755
}
end
describe file("#{default['puppetvardir']}/concat/bin") do
it { should be_directory }
it { should be_owned_by username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
should be_mode 755
}
end
describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do
it { should be_file }
it { should be_owned_by username }
#it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
should be_mode 755
}
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do
it { should be_directory }
it { should be_owned_by username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
should be_mode 750
}
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do
it { should be_directory }
it { should be_owned_by username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
should be_mode 750
}
end
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do
it { should be_file }
it { should be_owned_by username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
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 username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
should be_mode 640
}
end
end
context 'owner/group root' do
pp = <<-EOS
concat { '#{basedir}/file':
owner => '#{username}',
group => '#{groupname}',
mode => '0644',
}
concat::fragment { '1':
target => '#{basedir}/file',
content => '1',
order => '01',
}
concat::fragment { '2':
target => '#{basedir}/file',
content => '2',
order => '02',
}
EOS
it_behaves_like 'successfully_applied', pp
describe file('#{basedir}/file') do
it { should be_file }
it { should be_owned_by username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
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 username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
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 username }
it { should be_grouped_into groupname }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
should be_mode 640
}
end
end
context 'ensure' do
context 'works when set to present with path set' do
pp="
concat { 'file':
ensure => present,
path => '#{basedir}/file',
mode => '0644',
}
concat::fragment { '1':
target => 'file',
content => '1',
order => '01',
}
"
it_behaves_like 'successfully_applied', pp
describe file('#{basedir}/file') do
it { should be_file }
it("should be mode", :unless => (fact('osfamily') == 'AIX')) {
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 => '#{basedir}/file',
mode => '0644',
}
concat::fragment { '1':
target => 'file',
content => '1',
order => '01',
}
"
it 'applies the manifest twice with no stderr' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file('#{basedir}/file') do
it { should_not be_file }
end
end
end
end