2014-01-15 20:16:49 +01:00
require 'spec_helper_acceptance'
2013-10-29 23:39:54 +01:00
describe 'deprecation warnings' do
shared_examples 'has_warning' do | pp , w |
2014-01-15 20:16:49 +01:00
it 'applies the manifest twice with a stderr regex' do
expect ( apply_manifest ( pp , :catch_failures = > true ) . stderr ) . to match ( / #{ Regexp . escape ( w ) } /m )
expect ( apply_manifest ( pp , :catch_changes = > true ) . stderr ) . to match ( / #{ Regexp . escape ( w ) } /m )
2013-10-29 23:39:54 +01:00
end
end
context 'concat gnu parameter' do
2013-11-14 04:28:27 +01:00
pp = <<-EOS
2013-11-06 04:40:03 +01:00
concat { '/tmp/concat/file' :
2013-10-29 23:39:54 +01:00
gnu = > 'foo' ,
}
concat :: fragment { 'foo' :
2013-12-06 00:01:17 +01:00
target = > '/tmp/concat/file' ,
content = > 'bar' ,
2013-10-29 23:39:54 +01:00
}
2013-11-14 04:28:27 +01:00
EOS
2013-10-29 23:39:54 +01:00
w = 'The $gnu parameter to concat is deprecated and has no effect'
it_behaves_like 'has_warning' , pp , w
end
2013-12-23 22:23:49 +01:00
context 'concat warn parameter =>' do
[ 'true' , 'yes' , 'on' ] . each do | warn |
context warn do
pp = <<-EOS
concat { '/tmp/concat/file' :
warn = > '#{warn}' ,
}
concat :: fragment { 'foo' :
target = > '/tmp/concat/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 ( '/tmp/concat/file' ) do
it { should be_file }
it { should contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain 'bar' }
end
end
end
[ 'false' , 'no' , 'off' ] . each do | warn |
context warn do
pp = <<-EOS
concat { '/tmp/concat/file' :
warn = > '#{warn}' ,
}
concat :: fragment { 'foo' :
target = > '/tmp/concat/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 ( '/tmp/concat/file' ) do
it { should be_file }
it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' }
it { should contain 'bar' }
end
end
end
end
2013-12-06 00:01:17 +01:00
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' )
end
pp = <<-EOS
concat { '/tmp/concat/file' : }
concat :: fragment { 'foo' :
target = > '/tmp/concat/file' ,
ensure = > '/tmp/concat/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
it { should be_file }
it { should contain 'file1 contents' }
end
2014-01-15 20:16:49 +01:00
describe 'the fragment can be changed from a symlink to a plain file' do
pp = <<-EOS
concat { '/tmp/concat/file' : }
concat :: fragment { 'foo' :
target = > '/tmp/concat/file' ,
content = > 'new content' ,
}
EOS
2013-12-06 00:01:17 +01:00
2014-01-15 20:16:49 +01:00
it 'applies the manifest twice with no stderr' do
expect ( apply_manifest ( pp , :catch_failures = > true ) . stderr ) . to eq ( " " )
expect ( apply_manifest ( pp , :catch_changes = > true ) . stderr ) . to eq ( " " )
end
2013-12-06 00:01:17 +01:00
2014-01-15 20:16:49 +01:00
describe file ( '/tmp/concat/file' ) do
it { should be_file }
it { should contain 'new content' }
it { should_not contain 'file1 contents' }
end
2013-12-06 00:01:17 +01:00
end
end # target file exists
context 'target does not exist' do
pp = <<-EOS
concat { '/tmp/concat/file' : }
concat :: fragment { 'foo' :
target = > '/tmp/concat/file' ,
ensure = > '/tmp/concat/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
it { should be_file }
end
2014-01-15 20:16:49 +01:00
describe 'the fragment can be changed from a symlink to a plain file' do
pp = <<-EOS
concat { '/tmp/concat/file' : }
concat :: fragment { 'foo' :
target = > '/tmp/concat/file' ,
content = > 'new content' ,
}
EOS
2013-12-06 00:01:17 +01:00
2014-01-15 20:16:49 +01:00
it 'applies the manifest twice with no stderr' do
expect ( apply_manifest ( pp , :catch_failures = > true ) . stderr ) . to eq ( " " )
expect ( apply_manifest ( pp , :catch_changes = > true ) . stderr ) . to eq ( " " )
end
2013-12-06 00:01:17 +01:00
2014-01-15 20:16:49 +01:00
describe file ( '/tmp/concat/file' ) do
it { should be_file }
it { should contain 'new content' }
end
2013-12-06 00:01:17 +01:00
end
end # target file exists
end # concat::fragment ensure parameter
2013-11-02 18:45:02 +01:00
context 'concat::fragment mode parameter' do
2013-11-14 04:28:27 +01:00
pp = <<-EOS
2013-11-06 04:40:03 +01:00
concat { '/tmp/concat/file' : }
2013-11-02 18:45:02 +01:00
concat :: fragment { 'foo' :
2013-12-06 00:01:17 +01:00
target = > '/tmp/concat/file' ,
content = > 'bar' ,
mode = > 'bar' ,
2013-11-02 18:45:02 +01:00
}
2013-11-14 04:28:27 +01:00
EOS
2013-11-02 18:45:02 +01:00
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
2013-11-14 04:28:27 +01:00
pp = <<-EOS
2013-11-06 04:40:03 +01:00
concat { '/tmp/concat/file' : }
2013-11-02 18:45:02 +01:00
concat :: fragment { 'foo' :
2013-12-06 00:01:17 +01:00
target = > '/tmp/concat/file' ,
content = > 'bar' ,
owner = > 'bar' ,
2013-11-02 18:45:02 +01:00
}
2013-11-14 04:28:27 +01:00
EOS
2013-11-02 18:45:02 +01:00
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
2013-11-14 04:28:27 +01:00
pp = <<-EOS
2013-11-06 04:40:03 +01:00
concat { '/tmp/concat/file' : }
2013-11-02 18:45:02 +01:00
concat :: fragment { 'foo' :
2013-12-06 00:01:17 +01:00
target = > '/tmp/concat/file' ,
content = > 'bar' ,
group = > 'bar' ,
2013-11-02 18:45:02 +01:00
}
2013-11-14 04:28:27 +01:00
EOS
2013-11-02 18:45:02 +01:00
w = 'The $group parameter to concat::fragment is deprecated and has no effect'
it_behaves_like 'has_warning' , pp , w
end
2013-10-29 23:39:54 +01:00
context 'concat::fragment backup parameter' do
2013-11-14 04:28:27 +01:00
pp = <<-EOS
2013-11-06 04:40:03 +01:00
concat { '/tmp/concat/file' : }
2013-10-29 23:39:54 +01:00
concat :: fragment { 'foo' :
2013-12-06 00:01:17 +01:00
target = > '/tmp/concat/file' ,
content = > 'bar' ,
backup = > 'bar' ,
2013-10-29 23:39:54 +01:00
}
2013-11-14 04:28:27 +01:00
EOS
2013-10-29 23:39:54 +01:00
w = 'The $backup parameter to concat::fragment is deprecated and has no effect'
it_behaves_like 'has_warning' , pp , w
end
context 'include concat::setup' do
2013-11-14 04:28:27 +01:00
pp = <<-EOS
2013-10-29 23:39:54 +01:00
include concat :: setup
2013-11-14 04:28:27 +01:00
EOS
2013-10-29 23:39:54 +01:00
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