Skip to content

Commit

Permalink
Spec tests for apt-mark
Browse files Browse the repository at this point in the history
  • Loading branch information
chelnak committed Aug 12, 2022
1 parent 428beff commit 75cef27
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion spec/defines/mark_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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

Expand All @@ -47,4 +47,50 @@
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

0 comments on commit 75cef27

Please sign in to comment.