Skip to content

Commit 79bec3d

Browse files
committed
Add spec tests for apt-mark
This commit adds additional spec tests for mark.pp. The tests validate the new resource name requirements introduced in the previous commit.
1 parent eed10ea commit 79bec3d

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

spec/defines/mark_spec.rb

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
end
3333

3434
it {
35-
is_expected.to contain_exec('/usr/bin/apt-mark manual my_source')
35+
is_expected.to contain_exec('apt-mark manual my_source')
3636
}
3737
end
3838

@@ -47,4 +47,50 @@
4747
is_expected.to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'})
4848
end
4949
end
50+
51+
[
52+
'package',
53+
'package1',
54+
'package_name',
55+
'package-name',
56+
].each do |value|
57+
describe 'with a valid resource title' do
58+
let :title do
59+
value
60+
end
61+
62+
let :params do
63+
{
64+
'setting' => 'manual',
65+
}
66+
end
67+
68+
it do
69+
is_expected.to contain_exec("apt-mark manual #{title}")
70+
end
71+
end
72+
end
73+
74+
[
75+
'|| ls -la ||',
76+
'packakge with space',
77+
'package<>|',
78+
'|| touch /tmp/foo.txt ||',
79+
].each do |value|
80+
describe 'with an invalid resource title' do
81+
let :title do
82+
value
83+
end
84+
85+
let :params do
86+
{
87+
'setting' => 'manual',
88+
}
89+
end
90+
91+
it do
92+
is_expected.to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}})
93+
end
94+
end
95+
end
5096
end

0 commit comments

Comments
 (0)