Try to remove all the platform dependent stuff

And updated the tests to work as planned
This commit is contained in:
Morgan Haskel 2014-09-11 12:18:05 -04:00
parent 13c7653f57
commit 344f6adb36
4 changed files with 108 additions and 83 deletions

View file

@ -2,17 +2,25 @@ require 'spec_helper_acceptance'
case fact('osfamily')
when 'AIX'
username = 'root'
groupname = 'system'
username = 'root'
groupname = 'system'
scriptname = 'concatfragments.sh'
when 'Darwin'
username = 'root'
groupname = 'wheel'
username = 'root'
groupname = 'wheel'
scriptname = 'concatfragments.sh'
when 'windows'
username = 'Administrator'
groupname = 'Administrators'
username = 'Administrator'
groupname = 'Administrators'
scriptname = 'concatfragments.rb'
when 'solaris'
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.rb'
else
username = 'root'
groupname = 'root'
username = 'root'
groupname = 'root'
scriptname = 'concatfragments.sh'
end
describe 'basic concat test' do
@ -28,7 +36,6 @@ describe 'basic concat test' do
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
}
@ -36,15 +43,13 @@ describe 'basic concat test' do
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
describe file("#{default['puppetvardir']}/concat/bin/#{scriptname}") 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
}
@ -52,7 +57,6 @@ describe 'basic concat test' do
describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_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
}
@ -60,7 +64,6 @@ describe 'basic concat test' do
describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_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
}
@ -68,7 +71,6 @@ describe 'basic concat test' do
describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_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
}
@ -76,7 +78,6 @@ describe 'basic concat test' do
describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_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
}
@ -127,7 +128,6 @@ describe 'basic concat test' do
describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_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
}
@ -135,7 +135,6 @@ describe 'basic concat test' do
describe file("#{default['puppetvardir']}/concat/#{safe_basedir}_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
}

View file

@ -1,6 +1,7 @@
require 'spec_helper_acceptance'
describe 'deprecation warnings' do
basedir = default.tmpdir('concat')
shared_examples 'has_warning'do |pp, w|
it 'applies the manifest twice with a stderr regex' do
@ -11,11 +12,11 @@ describe 'deprecation warnings' do
context 'concat gnu parameter' do
pp = <<-EOS
concat { '/tmp/concat/file':
concat { '#{basedir}/file':
gnu => 'foo',
}
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'bar',
}
EOS
@ -28,11 +29,11 @@ describe 'deprecation warnings' do
['true', 'yes', 'on'].each do |warn|
context warn do
pp = <<-EOS
concat { '/tmp/concat/file':
concat { '#{basedir}/file':
warn => '#{warn}',
}
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'bar',
}
EOS
@ -40,7 +41,7 @@ describe 'deprecation warnings' do
it_behaves_like 'has_warning', pp, w
describe file('/tmp/concat/file') do
describe file("#{basedir}/file") do
it { should be_file }
it { should contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain 'bar' }
@ -51,11 +52,11 @@ describe 'deprecation warnings' do
['false', 'no', 'off'].each do |warn|
context warn do
pp = <<-EOS
concat { '/tmp/concat/file':
concat { '#{basedir}/file':
warn => '#{warn}',
}
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'bar',
}
EOS
@ -63,7 +64,7 @@ describe 'deprecation warnings' do
it_behaves_like 'has_warning', pp, w
describe file('/tmp/concat/file') do
describe file("#{basedir}/file") do
it { should be_file }
it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain 'bar' }
@ -75,37 +76,39 @@ describe 'deprecation warnings' do
context 'concat::fragment ensure parameter' do
context 'target file exists' do
before(:all) do
shell("/bin/echo 'file1 contents' > /tmp/concat/file1")
end
after(:all) do
# XXX this test may leave behind a symlink in the fragment directory
# which could cause warnings and/or breakage from the subsequent tests
# unless we clean it up.
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir -p /tmp/concat')
shell("/bin/echo 'file1 contents' > #{basedir}/file1")
pp = <<-EOS
file { '#{basedir}':
ensure => directory,
}
file { '#{basedir}/file1':
content => "file1 contents\n",
}
EOS
apply_manifest(pp)
end
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
ensure => '/tmp/concat/file1',
target => '#{basedir}/file',
ensure => '#{basedir}/file1',
}
EOS
w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.'
it_behaves_like 'has_warning', pp, w
describe file('/tmp/concat/file') do
describe file("#{basedir}/file") do
it { should be_file }
it { should contain 'file1 contents' }
end
describe 'the fragment can be changed from a symlink to a plain file' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'new content',
}
EOS
@ -115,7 +118,7 @@ describe 'deprecation warnings' do
apply_manifest(pp, :catch_changes => true)
end
describe file('/tmp/concat/file') do
describe file("#{basedir}/file") do
it { should be_file }
it { should contain 'new content' }
it { should_not contain 'file1 contents' }
@ -125,25 +128,25 @@ describe 'deprecation warnings' do
context 'target does not exist' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
ensure => '/tmp/concat/file1',
target => '#{basedir}/file',
ensure => '#{basedir}/file1',
}
EOS
w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.'
it_behaves_like 'has_warning', pp, w
describe file('/tmp/concat/file') do
describe file("#{basedir}/file") do
it { should be_file }
end
describe 'the fragment can be changed from a symlink to a plain file' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'new content',
}
EOS
@ -153,7 +156,7 @@ describe 'deprecation warnings' do
apply_manifest(pp, :catch_changes => true)
end
describe file('/tmp/concat/file') do
describe file("#{basedir}/file") do
it { should be_file }
it { should contain 'new content' }
end
@ -164,9 +167,9 @@ describe 'deprecation warnings' do
context 'concat::fragment mode parameter' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'bar',
mode => 'bar',
}
@ -178,9 +181,9 @@ describe 'deprecation warnings' do
context 'concat::fragment owner parameter' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'bar',
owner => 'bar',
}
@ -192,9 +195,9 @@ describe 'deprecation warnings' do
context 'concat::fragment group parameter' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'bar',
group => 'bar',
}
@ -206,9 +209,9 @@ describe 'deprecation warnings' do
context 'concat::fragment backup parameter' do
pp = <<-EOS
concat { '/tmp/concat/file': }
concat { '#{basedir}/file': }
concat::fragment { 'foo':
target => '/tmp/concat/file',
target => '#{basedir}/file',
content => 'bar',
backup => 'bar',
}

View file

@ -1,25 +1,31 @@
require 'spec_helper_acceptance'
describe 'concat::fragment replace' do
basedir = default.tmpdir('concat')
context 'should create fragment files' do
before(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir /tmp/concat')
pp = <<-EOS
file { '#{basedir}':
ensure => directory,
}
EOS
apply_manifest(pp)
end
pp1 = <<-EOS
concat { '/tmp/concat/foo': }
concat { '#{basedir}/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
target => '#{basedir}/foo',
content => 'caller has replace unset run 1',
}
EOS
pp2 = <<-EOS
concat { '/tmp/concat/foo': }
concat { '#{basedir}/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
target => '#{basedir}/foo',
content => 'caller has replace unset run 2',
}
EOS
@ -31,7 +37,7 @@ describe 'concat::fragment replace' do
apply_manifest(pp2, :catch_changes => true)
end
describe file('/tmp/concat/foo') do
describe file("#{basedir}/foo") do
it { should be_file }
it { should_not contain 'caller has replace unset run 1' }
it { should contain 'caller has replace unset run 2' }
@ -40,25 +46,29 @@ describe 'concat::fragment replace' do
context 'should replace its own fragment files when caller has File { replace=>true } set' do
before(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir /tmp/concat')
pp = <<-EOS
file { '#{basedir}':
ensure => directory,
}
EOS
apply_manifest(pp)
end
pp1 = <<-EOS
File { replace=>true }
concat { '/tmp/concat/foo': }
concat { '#{basedir}/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
target => '#{basedir}/foo',
content => 'caller has replace true set run 1',
}
EOS
pp2 = <<-EOS
File { replace=>true }
concat { '/tmp/concat/foo': }
concat { '#{basedir}/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
target => '#{basedir}/foo',
content => 'caller has replace true set run 2',
}
EOS
@ -70,7 +80,7 @@ describe 'concat::fragment replace' do
apply_manifest(pp2, :catch_changes => true)
end
describe file('/tmp/concat/foo') do
describe file("#{basedir}/foo") do
it { should be_file }
it { should_not contain 'caller has replace true set run 1' }
it { should contain 'caller has replace true set run 2' }
@ -79,25 +89,29 @@ describe 'concat::fragment replace' do
context 'should replace its own fragment files even when caller has File { replace=>false } set' do
before(:all) do
shell('rm -rf /tmp/concat /var/lib/puppet/concat')
shell('mkdir /tmp/concat')
pp = <<-EOS
file { '#{basedir}':
ensure => directory,
}
EOS
apply_manifest(pp)
end
pp1 = <<-EOS
File { replace=>false }
concat { '/tmp/concat/foo': }
concat { '#{basedir}/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
target => '#{basedir}/foo',
content => 'caller has replace false set run 1',
}
EOS
pp2 = <<-EOS
File { replace=>false }
concat { '/tmp/concat/foo': }
concat { '#{basedir}/foo': }
concat::fragment { '1':
target => '/tmp/concat/foo',
target => '#{basedir}/foo',
content => 'caller has replace false set run 2',
}
EOS
@ -109,7 +123,7 @@ describe 'concat::fragment replace' do
apply_manifest(pp2, :catch_changes => true)
end
describe file('/tmp/concat/foo') do
describe file("#{basedir}/foo") do
it { should be_file }
it { should_not contain 'caller has replace false set run 1' }
it { should contain 'caller has replace false set run 2' }

View file

@ -1,21 +1,30 @@
require 'spec_helper_acceptance'
describe 'quoted paths' do
basedir = default.tmpdir('concat')
before(:all) do
shell('rm -rf "/tmp/concat test" /var/lib/puppet/concat')
shell('mkdir -p "/tmp/concat test"')
pp = <<-EOS
file { '#{basedir}':
ensure => directory,
}
file { '#{basedir}/concat test':
ensure => directory,
}
EOS
apply_manifest(pp)
end
context 'path with blanks' do
pp = <<-EOS
concat { '/tmp/concat test/foo':
concat { '#{basedir}/concat test/foo':
}
concat::fragment { '1':
target => '/tmp/concat test/foo',
target => '#{basedir}/concat test/foo',
content => 'string1',
}
concat::fragment { '2':
target => '/tmp/concat test/foo',
target => '#{basedir}/concat test/foo',
content => 'string2',
}
EOS
@ -25,7 +34,7 @@ describe 'quoted paths' do
apply_manifest(pp, :catch_changes => true)
end
describe file('/tmp/concat test/foo') do
describe file("#{basedir}/concat test/foo") do
it { should be_file }
it { should contain "string1\nsring2" }
end