X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fconcat%2Fspec%2Facceptance%2Fdeprecation_warnings_spec.rb;h=11133ea9f299ac7ac2a072a5990722a32f14ad81;hb=917f80937c03a7f486d25fa70373f1f4d4b02958;hp=8a689a76b52e152539a930f87dd32d528425f702;hpb=ad88f67c13ae0f1a08936dad643f1e3509ab5f40;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/concat/spec/acceptance/deprecation_warnings_spec.rb b/3rdparty/modules/concat/spec/acceptance/deprecation_warnings_spec.rb index 8a689a76b..11133ea9f 100644 --- a/3rdparty/modules/concat/spec/acceptance/deprecation_warnings_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/deprecation_warnings_spec.rb @@ -10,35 +10,229 @@ describe 'deprecation warnings' do end end - context 'concat force parameter' do + context 'concat gnu parameter' do pp = <<-EOS concat { '#{basedir}/file': - force => false, + gnu => 'foo', } concat::fragment { 'foo': target => '#{basedir}/file', content => 'bar', } EOS - w = 'The $force parameter to concat is deprecated and has no effect.' + w = 'The $gnu parameter to concat is deprecated and has no effect' it_behaves_like 'has_warning', pp, w end - context 'concat::fragment ensure parameter' do + context 'concat warn parameter =>' do + ['true', 'yes', 'on'].each do |warn| + context warn do + pp = <<-EOS + concat { '#{basedir}/file': + warn => '#{warn}', + } + concat::fragment { 'foo': + target => '#{basedir}/file', + content => 'bar', + } + EOS + w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' + + it_behaves_like 'has_warning', pp, w + + describe file("#{basedir}/file") do + it { should be_file } + its(:content) { + should match '# This file is managed by Puppet. DO NOT EDIT.' + should match 'bar' + } + end + end + end + + ['false', 'no', 'off'].each do |warn| + context warn do + pp = <<-EOS + concat { '#{basedir}/file': + warn => '#{warn}', + } + concat::fragment { 'foo': + target => '#{basedir}/file', + content => 'bar', + } + EOS + w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' + + it_behaves_like 'has_warning', pp, w + + describe file("#{basedir}/file") do + it { should be_file } + its(:content) { + should_not match '# This file is managed by Puppet. DO NOT EDIT.' + should match 'bar' + } + end + end + end + end + + context 'concat::fragment ensure parameter', :unless => fact('osfamily') == 'windows' do context 'target file exists' do + before(:all) do + pp = <<-EOS + file { '#{basedir}': + ensure => directory, + } + file { '#{basedir}/file1': + content => "file1 contents\n", + } + EOS + apply_manifest(pp) + end + + pp = <<-EOS + concat { '#{basedir}/file': } + concat::fragment { 'foo': + 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("#{basedir}/file") do + it { should be_file } + its(:content) { should match 'file1 contents' } + end + + describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact("osfamily") == "windows") do + pp = <<-EOS + concat { '#{basedir}/file': } + concat::fragment { 'foo': + target => '#{basedir}/file', + content => 'new content', + } + EOS + + 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 be_file } + its(:content) { + should match 'new content' + should_not match 'file1 contents' + } + end + end + end # target file exists + + context 'target does not exist', :unless => fact('osfamily') == 'windows' do + pp = <<-EOS + concat { '#{basedir}/file': } + concat::fragment { 'foo': + 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("#{basedir}/file") do + it { should be_file } + end + + describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact('osfamily') == 'windows') do + pp = <<-EOS + concat { '#{basedir}/file': } + concat::fragment { 'foo': + target => '#{basedir}/file', + content => 'new content', + } + EOS + + 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 be_file } + its(:content) { should match 'new content' } + end + end + end # target file exists + + end # concat::fragment ensure parameter + + context 'concat::fragment mode parameter' do pp = <<-EOS - concat { '#{basedir}/file': + concat { '#{basedir}/file': } + concat::fragment { 'foo': + target => '#{basedir}/file', + content => 'bar', + mode => 'bar', } + EOS + w = 'The $mode parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment owner parameter' do + pp = <<-EOS + concat { '#{basedir}/file': } concat::fragment { 'foo': target => '#{basedir}/file', - ensure => false, content => 'bar', + owner => 'bar', } EOS - w = 'The $ensure parameter to concat::fragment is deprecated and has no effect.' + w = 'The $owner parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment group parameter' do + pp = <<-EOS + concat { '#{basedir}/file': } + concat::fragment { 'foo': + target => '#{basedir}/file', + content => 'bar', + group => 'bar', + } + EOS + w = 'The $group parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment backup parameter' do + pp = <<-EOS + concat { '#{basedir}/file': } + concat::fragment { 'foo': + target => '#{basedir}/file', + content => 'bar', + backup => 'bar', + } + EOS + w = 'The $backup parameter to concat::fragment is deprecated and has no effect' it_behaves_like 'has_warning', pp, w - end end + + context 'include concat::setup' do + pp = <<-EOS + include concat::setup + EOS + w = 'concat::setup is deprecated as a public API of the concat module and should no longer be directly included in the manifest.' + + it_behaves_like 'has_warning', pp, w + end + end