Skip to content

Commit

Permalink
Add unit tests for validate_cmd parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkeyes committed Nov 16, 2014
1 parent 09a01d8 commit 79c5e45
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions spec/unit/defines/concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:replace => true,
:order => 'alpha',
:ensure_newline => false,
:validate_cmd => nil,
}.merge(params)

safe_name = title.gsub('/', '_')
Expand Down Expand Up @@ -76,15 +77,16 @@

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

Expand Down Expand Up @@ -380,6 +382,22 @@
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
Expand Down

0 comments on commit 79c5e45

Please sign in to comment.