X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fmark_spec.rb;h=6c673c41c36ae4fbd48470daba9a2f8acedfadef;hb=refs%2Fheads%2Fmaint-move_apt_mark_to_provider;hp=b451bedd30673e20813b4519a91619a49e40c174;hpb=eed10ea359d0fe144da90a8425cd14dc3c6c8f18;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/mark_spec.rb b/spec/defines/mark_spec.rb index b451bed..6c673c4 100644 --- a/spec/defines/mark_spec.rb +++ b/spec/defines/mark_spec.rb @@ -32,7 +32,7 @@ describe 'apt::mark', type: :define do end it { - is_expected.to contain_exec('/usr/bin/apt-mark manual my_source') + is_expected.to contain_exec('apt-mark manual my_source') } end @@ -47,4 +47,50 @@ describe 'apt::mark', type: :define do is_expected.to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'}) end end + + [ + 'package', + 'package1', + 'package_name', + 'package-name', + ].each do |value| + describe 'with a valid resource title' do + let :title do + value + end + + let :params do + { + 'setting' => 'manual', + } + end + + it do + is_expected.to contain_exec("apt-mark manual #{title}") + end + end + end + + [ + '|| ls -la ||', + 'packakge with space', + 'package<>|', + '|| touch /tmp/foo.txt ||', + ].each do |value| + describe 'with an invalid resource title' do + let :title do + value + end + + let :params do + { + 'setting' => 'manual', + } + end + + it do + is_expected.to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}}) + end + end + end end