Add unit tests for validate_cmd parameter.

This commit is contained in:
Joshua M. Keyes 2014-11-15 16:49:00 -08:00
parent 09a01d8087
commit 79c5e45a24

View file

@ -19,6 +19,7 @@ describe 'concat', :type => :define do
:replace => true,
:order => 'alpha',
:ensure_newline => false,
:validate_cmd => nil,
}.merge(params)
safe_name = title.gsub('/', '_')
@ -76,15 +77,16 @@ describe 'concat', :type => :define do
it do
should contain_file(title).with(file_defaults.merge({
:ensure => 'present',
:owner => p[:owner],
:group => p[:group],
:mode => p[:mode],
:replace => p[:replace],
:path => p[:path],
:alias => "concat_#{title}",
:source => "#{fragdir}/#{concat_name}",
:backup => p[:backup],
:ensure => 'present',
:owner => p[:owner],
:group => p[:group],
:mode => p[:mode],
:replace => p[:replace],
:path => p[:path],
:alias => "concat_#{title}",
:source => "#{fragdir}/#{concat_name}",
:validate_cmd => p[:validate_cmd],
:backup => p[:backup],
}))
end
@ -380,6 +382,22 @@ describe 'concat', :type => :define do
end
end # ensure_newline =>
context 'validate_cmd =>' do
context '/usr/bin/test -e %' do
it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e %' }
end
[ 1234, true ].each do |cmd|
context cmd do
let(:title) { '/etc/foo.bar' }
let(:params) {{ :validate_cmd => cmd }}
it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/)
end
end
end
end # validate_cmd =>
describe 'deprecated parameter' do
context 'gnu =>' do
context 'foo' do