Merge pull request #94 from jhoblitt/symbolic_names

allow concat::fragment target param to be an arbitrary string
This commit is contained in:
Ashley Penney 2013-11-02 13:13:08 -07:00
commit 7db163cd64
3 changed files with 54 additions and 11 deletions

View file

@ -35,7 +35,7 @@ define concat::fragment(
$group = undef,
$backup = undef
) {
validate_absolute_path($target)
validate_string($target)
validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$')
validate_string($content)
validate_string($source)

View file

@ -0,0 +1,35 @@
require 'spec_helper_system'
describe 'symbolic name' do
pp="
concat { 'not_abs_path':
path => '/tmp/file',
}
concat::fragment { '1':
target => 'not_abs_path',
content => '1',
order => '01',
}
concat::fragment { '2':
target => 'not_abs_path',
content => '2',
order => '02',
}
"
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
describe file('/tmp/file') do
it { should be_file }
it { should contain '1' }
it { should contain '2' }
end
end

View file

@ -44,22 +44,30 @@ describe 'concat::fragment', :type => :define do
end
end
context 'target =>' do
context '/etc/motd' do
it_behaves_like 'fragment', 'motd_header', {
context 'title' do
['0', '1', 'a', 'z'].each do |title|
it_behaves_like 'fragment', title, {
:target => '/etc/motd',
}
end
end # title
['./etc/motd', 'etc/motd', false].each do |target|
context 'target =>' do
['./etc/motd', 'etc/motd', 'motd_header'].each do |target|
context target do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }}
let(:params) {{ :target => target }}
it_behaves_like 'fragment', target, {
:target => '/etc/motd',
}
end
end
it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /is not an absolute path/)
end
context 'false' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp' }}
let(:params) {{ :target => false }}
it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /is not a string/)
end
end
end # target =>