2014-01-15 20:16:49 +01:00
require 'spec_helper_acceptance'
2013-10-29 23:39:54 +01:00
describe 'deprecation warnings' do
2014-09-11 18:18:05 +02:00
basedir = default . tmpdir ( 'concat' )
2013-10-29 23:39:54 +01:00
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
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' :
2013-10-29 23:39:54 +01:00
gnu = > 'foo' ,
}
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2013-12-06 00:01:17 +01:00
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
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' :
2013-12-23 22:23:49 +01:00
warn = > '#{warn}' ,
}
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2013-12-23 22:23:49 +01:00
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
2014-09-11 18:18:05 +02:00
describe file ( " #{ basedir } /file " ) do
2013-12-23 22:23:49 +01:00
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
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' :
2013-12-23 22:23:49 +01:00
warn = > '#{warn}' ,
}
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2013-12-23 22:23:49 +01:00
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
2014-09-11 18:18:05 +02:00
describe file ( " #{ basedir } /file " ) do
2013-12-23 22:23:49 +01:00
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
2014-10-03 21:01:20 +02:00
context 'concat::fragment ensure parameter' , :unless = > fact ( 'osfamily' ) == 'windows' do
2013-12-06 00:01:17 +01:00
context 'target file exists' do
before ( :all ) do
2014-09-11 18:18:05 +02:00
pp = <<-EOS
file { '#{basedir}' :
ensure = > directory ,
}
file { '#{basedir}/file1' :
content = > " file1 contents \n " ,
}
EOS
apply_manifest ( pp )
2013-12-06 00:01:17 +01:00
end
pp = <<-EOS
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2013-12-06 00:01:17 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
ensure = > '#{basedir}/file1' ,
2013-12-06 00:01:17 +01:00
}
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
2014-09-11 18:18:05 +02:00
describe file ( " #{ basedir } /file " ) do
2013-12-06 00:01:17 +01:00
it { should be_file }
it { should contain 'file1 contents' }
end
2014-09-11 21:41:41 +02:00
describe 'the fragment can be changed from a symlink to a plain file' , :unless = > ( fact ( " osfamily " ) == " windows " ) do
2014-01-15 20:16:49 +01:00
pp = <<-EOS
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2014-01-15 20:16:49 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2014-01-15 20:16:49 +01:00
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
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
2013-12-06 00:01:17 +01:00
2014-09-11 18:18:05 +02:00
describe file ( " #{ basedir } /file " ) do
2014-01-15 20:16:49 +01:00
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
2014-10-03 21:01:20 +02:00
context 'target does not exist' , :unless = > fact ( 'osfamily' ) == 'windows' do
2013-12-06 00:01:17 +01:00
pp = <<-EOS
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2013-12-06 00:01:17 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
ensure = > '#{basedir}/file1' ,
2013-12-06 00:01:17 +01:00
}
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
2014-09-11 18:18:05 +02:00
describe file ( " #{ basedir } /file " ) do
2013-12-06 00:01:17 +01:00
it { should be_file }
end
2014-09-11 21:41:41 +02:00
describe 'the fragment can be changed from a symlink to a plain file' , :unless = > ( fact ( 'osfamily' ) == 'windows' ) do
2014-01-15 20:16:49 +01:00
pp = <<-EOS
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2014-01-15 20:16:49 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2014-01-15 20:16:49 +01:00
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
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
2013-12-06 00:01:17 +01:00
2014-09-11 18:18:05 +02:00
describe file ( " #{ basedir } /file " ) do
2014-01-15 20:16:49 +01:00
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
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2013-11-02 18:45:02 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2013-12-06 00:01:17 +01:00
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
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2013-11-02 18:45:02 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2013-12-06 00:01:17 +01:00
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
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2013-11-02 18:45:02 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2013-12-06 00:01:17 +01:00
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
2014-09-11 18:18:05 +02:00
concat { '#{basedir}/file' : }
2013-10-29 23:39:54 +01:00
concat :: fragment { 'foo' :
2014-09-11 18:18:05 +02:00
target = > '#{basedir}/file' ,
2013-12-06 00:01:17 +01:00
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