Skip to content

Commit 558a978

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 558a978

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
'1',
14+
'1.1',
15+
].each do |value|
16+
describe value.inspect do
17+
it { is_expected.to allow_value(value) }
18+
end
19+
end
20+
end
21+
describe 'No complex types can match' do
22+
context 'garbage inputs, no complex types can match' do
23+
[
24+
1,
25+
1.1,
26+
[1.1],
27+
'',
28+
{ 'foo' => 'bar' },
29+
{},
30+
].each do |value|
31+
describe value.inspect do
32+
it { is_expected.not_to allow_value(value) }
33+
end
34+
end
35+
end
36+
end
37+
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)