Skip to content

Commit a2dfdba

Browse files
authored
Merge pull request #1281 from arjenz/package_type
Add Stdlib::Ensure::Package type
2 parents dfd9b30 + 28b7529 commit a2dfdba

File tree

2 files changed

+41
-0
lines changed

2 files changed

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

types/ensure/package.pp

+2
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)