diff options
Diffstat (limited to 'spec/aliases')
-rw-r--r-- | spec/aliases/absolute_path_spec.rb | 7 | ||||
-rw-r--r-- | spec/aliases/absolutepath_spec.rb | 49 | ||||
-rw-r--r-- | spec/aliases/array_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/bool_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/float_spec.rb | 4 | ||||
-rw-r--r-- | spec/aliases/hash_spec.rb | 32 | ||||
-rw-r--r-- | spec/aliases/httpsurl_spec.rb | 8 | ||||
-rw-r--r-- | spec/aliases/httpurl_spec.rb | 8 | ||||
-rw-r--r-- | spec/aliases/integer_spec.rb | 12 | ||||
-rw-r--r-- | spec/aliases/ip_address.rb | 2 | ||||
-rw-r--r-- | spec/aliases/ipv4_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/ipv6_spec.rb | 16 | ||||
-rw-r--r-- | spec/aliases/numeric_spec.rb | 4 | ||||
-rw-r--r-- | spec/aliases/string_spec.rb | 4 | ||||
-rw-r--r-- | spec/aliases/unixpath_spec.rb | 10 | ||||
-rw-r--r-- | spec/aliases/windowspath_spec.rb | 9 |
16 files changed, 96 insertions, 75 deletions
diff --git a/spec/aliases/absolute_path_spec.rb b/spec/aliases/absolute_path_spec.rb index 3fb9d12..308a3aa 100644 --- a/spec/aliases/absolute_path_spec.rb +++ b/spec/aliases/absolute_path_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::absolute_path', type: :class do describe 'valid paths handling' do %w{ @@ -15,6 +15,9 @@ if Puppet.version.to_f >= 4.5 / /var/tmp /var/opt/../lib/puppet + /var/opt//lib/puppet + /var/ůťƒ8 + /var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -50,6 +53,8 @@ if Puppet.version.to_f >= 4.5 etc/puppetlabs/puppet opt/puppet/bin relative\\windows + \var\ůťƒ8 + \var\ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb deleted file mode 100644 index aa435d7..0000000 --- a/spec/aliases/absolutepath_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' - -if Puppet.version.to_f >= 4.5 - describe 'test::absolutepath', type: :class do - describe 'valid handling' do - %w{ - /usr2/username/bin:/usr/local/bin:/usr/bin:. - C:/ - C:\\ - C:\\WINDOWS\\System32 - C:/windows/system32 - X:/foo/bar - X:\\foo\\bar - \\\\host\\windows - //host/windows - /var/tmp - /var/opt/../lib/puppet - }.each do |value| - describe value.inspect do - let(:params) {{ value: value }} - it { is_expected.to compile } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - nil, - [ nil ], - [ nil, nil ], - { 'foo' => 'bar' }, - { }, - '', - "*/Users//nope", - "\\Users/hc/wksp/stdlib", - "C:noslashes", - "\\var\\tmp" - ].each do |value| - describe value.inspect do - let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Variant/) } - end - end - end - - end - end -end diff --git a/spec/aliases/array_spec.rb b/spec/aliases/array_spec.rb index d0f9877..89cc2af 100644 --- a/spec/aliases/array_spec.rb +++ b/spec/aliases/array_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::array', type: :class do describe 'accepts arrays' do [ diff --git a/spec/aliases/bool_spec.rb b/spec/aliases/bool_spec.rb index 78c57fc..b84ab51 100644 --- a/spec/aliases/bool_spec.rb +++ b/spec/aliases/bool_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::bool', type: :class do describe 'accepts booleans' do [ diff --git a/spec/aliases/float_spec.rb b/spec/aliases/float_spec.rb index cc20758..84e1934 100644 --- a/spec/aliases/float_spec.rb +++ b/spec/aliases/float_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::float', type: :class do describe 'accepts floats' do [ @@ -20,7 +20,7 @@ if Puppet.version.to_f >= 4.5 [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3, '3', -3, '-3'].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Float or Pattern(\[.*\]+)?/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects.*Float.*Pattern/) } end end end diff --git a/spec/aliases/hash_spec.rb b/spec/aliases/hash_spec.rb new file mode 100644 index 0000000..6e5060d --- /dev/null +++ b/spec/aliases/hash_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'test::hash', type: :class do + describe 'accepts hashes' do + [ + {}, + {'one' => "two"}, + {'wan' => 3}, + {'001' => "helly"}, + ].each do |value| + describe value.inspect do + let(:params) {{ value: value }} + it { is_expected.to compile } + end + end + end + describe 'rejects other values' do + [ + '', + 'one', + '1', + [], + ].each do |value| + describe value.inspect do + let(:params) {{ value: value }} + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Hash/) } + end + end + end + end +end diff --git a/spec/aliases/httpsurl_spec.rb b/spec/aliases/httpsurl_spec.rb index 97ae006..3e51118 100644 --- a/spec/aliases/httpsurl_spec.rb +++ b/spec/aliases/httpsurl_spec.rb @@ -1,12 +1,14 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::httpsurl', type: :class do describe 'valid handling' do %w{ https://hello.com https://notcreative.org https://notexciting.co.uk + https://graphemica.com/❤ + https://graphemica.com/緩 }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -26,7 +28,9 @@ if Puppet.version.to_f >= 4.5 '', "httds://notquiteright.org", "hptts:/nah", - "https;//notrightbutclose.org" + "https;//notrightbutclose.org", + "http://graphemica.com/❤", + "http://graphemica.com/緩" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/httpurl_spec.rb b/spec/aliases/httpurl_spec.rb index 8bd57ca..fd49a47 100644 --- a/spec/aliases/httpurl_spec.rb +++ b/spec/aliases/httpurl_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::httpurl', type: :class do describe 'valid handling' do %w{ @@ -10,6 +10,8 @@ if Puppet.version.to_f >= 4.5 http://anhttp.com http://runningoutofideas.gov http:// + http://graphemica.com/❤ + http://graphemica.com/緩 }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -29,7 +31,9 @@ if Puppet.version.to_f >= 4.5 '', "httds://notquiteright.org", "hptts:/nah", - "https;//notrightbutclose.org" + "https;//notrightbutclose.org", + "hts://graphemica.com/❤", + "https:graphemica.com/緩" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb index 260090a..9cf0357 100644 --- a/spec/aliases/integer_spec.rb +++ b/spec/aliases/integer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::integer', type: :class do describe 'accepts integers' do [ @@ -8,6 +8,8 @@ if Puppet.version.to_f >= 4.5 '3', -3, '-3', + "123\nfoo", + "foo\n123", ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -17,10 +19,14 @@ if Puppet.version.to_f >= 4.5 end describe 'rejects other values' do - [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value| + [ "foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) } + if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a Stdlib::Compat::Integer = Variant\[Integer, Pattern\[.*\], Array\[.*\]\] value/) } + else + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) } + end end end end diff --git a/spec/aliases/ip_address.rb b/spec/aliases/ip_address.rb index 664bf24..67a555c 100644 --- a/spec/aliases/ip_address.rb +++ b/spec/aliases/ip_address.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::ip_address', type: :class do describe 'accepts ipv4 and ipv6 addresses' do [ diff --git a/spec/aliases/ipv4_spec.rb b/spec/aliases/ipv4_spec.rb index 210b4b1..6a503ad 100644 --- a/spec/aliases/ipv4_spec.rb +++ b/spec/aliases/ipv4_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::ipv4', type: :class do describe 'accepts ipv4 addresses' do SharedData::IPV4_PATTERNS.each do |value| diff --git a/spec/aliases/ipv6_spec.rb b/spec/aliases/ipv6_spec.rb index 13d7c3e..ae90f42 100644 --- a/spec/aliases/ipv6_spec.rb +++ b/spec/aliases/ipv6_spec.rb @@ -1,11 +1,18 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::ipv6', type: :class do describe 'accepts ipv6 addresses' do [ '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111' + 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', + 'fe80:0000:0000:0000:0204:61ff:fe9d:f156', + 'fe80:0:0:0:204:61ff:fe9d:f156', + 'fe80::204:61ff:fe9d:f156', + 'fe80:0:0:0:0204:61ff:254.157.241.86', + '::1', + 'fe80::', + '2001::', ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -18,7 +25,10 @@ if Puppet.version.to_f >= 4.5 'nope', '77', '4.4.4', - '2000:7334' + '2000:7334', + '::ffff:2.3.4', + '::ffff:257.1.2.3', + '::ffff:12345678901234567890.1.26', ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/numeric_spec.rb b/spec/aliases/numeric_spec.rb index 0e98bee..09c28ec 100644 --- a/spec/aliases/numeric_spec.rb +++ b/spec/aliases/numeric_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::numeric', type: :class do describe 'accepts numerics' do [ @@ -24,7 +24,7 @@ if Puppet.version.to_f >= 4.5 [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x' ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Numeric, Pattern(\[.*\]+)?, or Array/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects.*Numeric.*Pattern.*Array/) } end end end diff --git a/spec/aliases/string_spec.rb b/spec/aliases/string_spec.rb index 8a93585..4fc8ce6 100644 --- a/spec/aliases/string_spec.rb +++ b/spec/aliases/string_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::string', type: :class do describe 'accepts strings' do [ @@ -24,7 +24,7 @@ if Puppet.version.to_f >= 4.5 ].each do |value| describe value.inspect do let(:params) {{ value: value }} - it { is_expected.to compile.and_raise_error(/parameter 'value' expects a String/) } + it { is_expected.to compile.and_raise_error(/parameter 'value' expects a (?:value of type Undef or )?.*String/) } end end end diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb index aee161d..6aecfe7 100644 --- a/spec/aliases/unixpath_spec.rb +++ b/spec/aliases/unixpath_spec.rb @@ -1,12 +1,16 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::unixpath', type: :class do describe 'valid handling' do %w{ /usr2/username/bin:/usr/local/bin:/usr/bin:. /var/tmp /Users/helencampbell/workspace/puppetlabs-stdlib + /var/ůťƒ8 + /var/ネット + /var//tmp + /var/../tmp }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -27,7 +31,9 @@ if Puppet.version.to_f >= 4.5 "C:/whatever", "\\var\\tmp", "\\Users/hc/wksp/stdlib", - "*/Users//nope" + "*/Users//nope", + "var\ůťƒ8", + "var\ネット" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/windowspath_spec.rb b/spec/aliases/windowspath_spec.rb index c13794e..c20e373 100644 --- a/spec/aliases/windowspath_spec.rb +++ b/spec/aliases/windowspath_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::windowspath', type: :class do describe 'valid handling' do %w{ @@ -10,6 +10,8 @@ if Puppet.version.to_f >= 4.5 X:/foo/bar X:\\foo\\bar \\\\host\\windows + X:/var/ůťƒ8 + X:/var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -30,7 +32,9 @@ if Puppet.version.to_f >= 4.5 "httds://notquiteright.org", "/usr2/username/bin:/usr/local/bin:/usr/bin:.", "C;//notright/here", - "C:noslashes" + "C:noslashes", + "C:ネット", + "C:ůťƒ8" ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -38,7 +42,6 @@ if Puppet.version.to_f >= 4.5 end end end - end end end |