Skip to content

Commit eda6f2c

Browse files
committed
Fixes command
Correct command is `test -e $filename` Also % replacement in validate_cmd is not supported in a released version of puppetlabs-stdlib, it's fixed in 4.5.x but not not released yet (See: puppetlabs/puppetlabs-stdlib#377)
1 parent b5c7ee9 commit eda6f2c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
}
197197
}
198198
else {
199-
validate_cmd("${fragdir}/${concat_name}", $validate_cmd)
199+
fail("validate_cmd is a limted to Puppet > 3.5, you are on ${::puppetversion}")
200200
}
201201
}
202202

spec/unit/defines/concat_spec.rb

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
:replace => true,
2020
:order => 'alpha',
2121
:ensure_newline => false,
22-
:validate_cmd => nil,
2322
}.merge(params)
2423

2524
safe_name = title.gsub('/', '_')
@@ -88,9 +87,6 @@
8887
:source => "#{fragdir}/#{concat_name}",
8988
:backup => p[:backup],
9089
}))
91-
if (Puppet.version >= '3.5.0')
92-
contain_file(title).with(:validate_cmd => p[:validate_cmd])
93-
end
9490
end
9591

9692
cmd = "#{concatdir}/bin/concatfragments.sh " +
@@ -391,15 +387,24 @@
391387
end
392388

393389
context '/usr/bin/test -e' do
394-
it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test % -e' }
395-
end
396-
397-
[ 1234, true ].each do |cmd|
398-
context cmd do
390+
if (Puppet.version >= '3.5.0')
391+
let(:facts) {{ :puppetversion => Puppet.version }}
392+
it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e' }
393+
else
399394
let(:title) { '/etc/foo.bar' }
400-
let(:params) {{ :validate_cmd => cmd }}
395+
let(:facts) {
396+
{
397+
:puppetversion => Puppet.version,
398+
:concat_basedir => '/var/lib/puppet/concat',
399+
}
400+
}
401+
let(:params) {
402+
{
403+
:validate_cmd => '/usr/bin/test -e'
404+
}
405+
}
401406
it 'should fail' do
402-
expect { should }.to raise_error(Puppet::Error, /\$validate_cmd must be a string/)
407+
expect { should }.to raise_error(/validate_cmd is a limted to Puppet > 3.5, you are on/)
403408
end
404409
end
405410
end

0 commit comments

Comments
 (0)