Skip to content

Commit 1b4fb4e

Browse files
authored
Merge pull request #708 from HelenCampbell/hashcompat
Addition of compat hash type for deprecation
2 parents b65dd1f + 128d6fe commit 1b4fb4e

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

spec/aliases/hash_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'spec_helper'
2+
3+
if Puppet.version.to_f >= 4.5
4+
describe 'test::hash', type: :class do
5+
describe 'accepts hashes' do
6+
[
7+
{},
8+
{'one' => "two"},
9+
{'wan' => 3},
10+
{'001' => "helly"},
11+
].each do |value|
12+
describe value.inspect do
13+
let(:params) {{ value: value }}
14+
it { is_expected.to compile }
15+
end
16+
end
17+
end
18+
describe 'rejects other values' do
19+
[
20+
'',
21+
'one',
22+
'1',
23+
[],
24+
].each do |value|
25+
describe value.inspect do
26+
let(:params) {{ value: value }}
27+
it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Hash/) }
28+
end
29+
end
30+
end
31+
end
32+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Class to test the Stdlib::Compat::Hash type alias
2+
class test::hash(
3+
Stdlib::Compat::Hash $value,
4+
) {
5+
6+
notice("Success")
7+
8+
}

types/compat/hash.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Emulate the is_hash and validate_hash functions
2+
type Stdlib::Compat::Hash = Hash[Any, Any]

0 commit comments

Comments
 (0)