diff --git a/spec/type_aliases/ensure_package_spec.rb b/spec/type_aliases/ensure_package_spec.rb new file mode 100644 index 000000000..a907747e2 --- /dev/null +++ b/spec/type_aliases/ensure_package_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Stdlib::Ensure::Package' do + describe 'valid handling' do + [ + 'present', + 'absent', + 'purged', + 'disabled', + 'installed', + 'latest', + '1', + '1.1', + '>=6.0', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + describe 'No complex types can match' do + context 'Garbage inputs, no complex or non string types can match' do + [ + 1, + 1.1, + [1.1], + '', + { 'foo' => 'bar' }, + {}, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/types/ensure/package.pp b/types/ensure/package.pp new file mode 100644 index 000000000..3f6ad47c7 --- /dev/null +++ b/types/ensure/package.pp @@ -0,0 +1,2 @@ +# @summary Validate the value of the ensure parameter for a package +type Stdlib::Ensure::Package = Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]]