2014-01-15 20:16:49 +01:00
require 'spec_helper_acceptance'
describe 'concat backup parameter' do
2014-02-28 00:50:18 +01:00
basedir = default . tmpdir ( 'concat' )
2014-01-15 20:16:49 +01:00
context '=> puppet' do
2014-09-11 01:06:17 +02:00
before ( :all ) do
pp = <<-EOS
file { '#{basedir}' :
ensure = > directory ,
}
file { '#{basedir}/file' :
content = > " old contents \n " ,
}
EOS
apply_manifest ( pp )
end
2014-01-15 20:16:49 +01:00
pp = <<-EOS
2014-02-27 23:52:53 +01:00
concat { '#{basedir}/file' :
2014-09-11 01:06:17 +02:00
backup = > 'puppet' ,
2014-01-15 20:16:49 +01:00
}
concat :: fragment { 'new file' :
2014-02-27 23:52:53 +01:00
target = > '#{basedir}/file' ,
2014-01-15 20:16:49 +01:00
content = > 'new contents' ,
}
EOS
it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do
apply_manifest ( pp , :catch_failures = > true ) do | r |
2014-02-27 23:52:53 +01:00
expect ( r . stdout ) . to match ( / Filebucketed #{ basedir } \/ file to puppet with sum 0140c31db86293a1a1e080ce9b91305f / ) # sum is for file contents of 'old contents'
2014-01-15 20:16:49 +01:00
end
2014-09-08 21:01:30 +02:00
apply_manifest ( pp , :catch_changes = > true )
2014-01-15 20:16:49 +01:00
end
2014-02-27 23:52:53 +01:00
describe file ( " #{ basedir } /file " ) do
2014-01-15 20:16:49 +01:00
it { should be_file }
it { should contain 'new contents' }
end
end
context '=> .backup' do
2014-09-11 01:06:17 +02:00
before ( :all ) do
pp = <<-EOS
file { '#{basedir}' :
ensure = > directory ,
}
file { '#{basedir}/file' :
content = > " old contents \n " ,
}
EOS
apply_manifest ( pp )
end
2014-01-15 20:16:49 +01:00
pp = <<-EOS
2014-02-27 23:52:53 +01:00
concat { '#{basedir}/file' :
2014-09-11 01:06:17 +02:00
backup = > '.backup' ,
2014-01-15 20:16:49 +01:00
}
concat :: fragment { 'new file' :
2014-02-27 23:52:53 +01:00
target = > '#{basedir}/file' ,
2014-01-15 20:16:49 +01:00
content = > 'new contents' ,
}
EOS
# XXX Puppet doesn't mention anything about filebucketing with a given
# extension like .backup
it 'applies the manifest twice no stderr' do
2014-09-08 21:01:30 +02:00
apply_manifest ( pp , :catch_failures = > true )
apply_manifest ( pp , :catch_changes = > true )
2014-01-15 20:16:49 +01:00
end
2014-02-27 23:52:53 +01:00
describe file ( " #{ basedir } /file " ) do
2014-01-15 20:16:49 +01:00
it { should be_file }
it { should contain 'new contents' }
end
2014-02-27 23:52:53 +01:00
describe file ( " #{ basedir } /file.backup " ) do
2014-01-15 20:16:49 +01:00
it { should be_file }
it { should contain 'old contents' }
end
end
# XXX The backup parameter uses validate_string() and thus can't be the
# boolean false value, but the string 'false' has the same effect in Puppet 3
context " => 'false' " do
2014-09-11 01:06:17 +02:00
before ( :all ) do
pp = <<-EOS
file { '#{basedir}' :
ensure = > directory ,
}
file { '#{basedir}/file' :
content = > " old contents \n " ,
}
EOS
apply_manifest ( pp )
end
2014-01-15 20:16:49 +01:00
pp = <<-EOS
2014-02-27 23:52:53 +01:00
concat { '#{basedir}/file' :
2014-01-15 20:16:49 +01:00
backup = > '.backup' ,
}
concat :: fragment { 'new file' :
2014-02-27 23:52:53 +01:00
target = > '#{basedir}/file' ,
2014-01-15 20:16:49 +01:00
content = > 'new contents' ,
}
EOS
it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do
apply_manifest ( pp , :catch_failures = > true ) do | r |
expect ( r . stdout ) . to_not match ( / Filebucketed / )
end
2014-09-08 21:01:30 +02:00
apply_manifest ( pp , :catch_changes = > true )
2014-01-15 20:16:49 +01:00
end
2014-02-27 23:52:53 +01:00
describe file ( " #{ basedir } /file " ) do
2014-01-15 20:16:49 +01:00
it { should be_file }
it { should contain 'new contents' }
end
end
end