Skip to content

Commit 0147406

Browse files
committed
Add Stdlib::Ensure::Package type
Like the ones for file, service. Valid values taken from https://puppet.com/docs/puppet/7/types/package.html#package-attribute-ensure
1 parent dfd9b30 commit 0147406

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'Stdlib::Ensure::Package' do
6+
describe 'valid handling' do
7+
[
8+
'present',
9+
'absent',
10+
'purged',
11+
'disabled',
12+
'installed',
13+
'latest',
14+
'1',
15+
'1.1',
16+
].each do |value|
17+
describe value.inspect do
18+
it { is_expected.to allow_value(value) }
19+
end
20+
end
21+
end
22+
describe 'No complex types can match' do
23+
context 'garbage inputs, no complex types can match' do
24+
[
25+
1,
26+
1.1,
27+
[1.1],
28+
'',
29+
{ 'foo' => 'bar' },
30+
{},
31+
].each do |value|
32+
describe value.inspect do
33+
it { is_expected.not_to allow_value(value) }
34+
end
35+
end
36+
end
37+
end
38+
end

types/ensure/package.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# @summary Validate the value of the ensure parameter for a package
2+
type Stdlib::Ensure::Package = Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]]

0 commit comments

Comments
 (0)