diff options
author | David Schmitt <david.schmitt@puppet.com> | 2016-10-07 14:43:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-07 14:43:05 +0100 |
commit | 527a4f1ebc21276458427fc5787a621fa8d5cb67 (patch) | |
tree | 3460fdc969438937c1e1c9cd173fb5e1193b54dd /spec | |
parent | db8edf5cb36e038c747d177914aaa747c770477d (diff) | |
parent | 83539371e5b1e6ff412eda48c3a725653c506ece (diff) |
Merge pull request #664 from HelenCampbell/typeupdates
Type updates
Diffstat (limited to 'spec')
-rw-r--r-- | spec/aliases/absolute_path_spec.rb | 2 | ||||
-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 | 2 | ||||
-rw-r--r-- | spec/aliases/httpsurl_spec.rb | 40 | ||||
-rw-r--r-- | spec/aliases/httpurl_spec.rb | 43 | ||||
-rw-r--r-- | spec/aliases/integer_spec.rb | 2 | ||||
-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 | 2 | ||||
-rw-r--r-- | spec/aliases/numeric_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/string_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/unixpath_spec.rb | 41 | ||||
-rw-r--r-- | spec/aliases/windowspath_spec.rb | 44 | ||||
-rw-r--r-- | spec/fixtures/test/manifests/absolutepath.pp | 6 | ||||
-rw-r--r-- | spec/fixtures/test/manifests/httpsurl.pp | 6 | ||||
-rw-r--r-- | spec/fixtures/test/manifests/httpurl.pp | 6 | ||||
-rw-r--r-- | spec/fixtures/test/manifests/unixpath.pp | 6 | ||||
-rw-r--r-- | spec/fixtures/test/manifests/windowspath.pp | 6 |
20 files changed, 257 insertions, 10 deletions
diff --git a/spec/aliases/absolute_path_spec.rb b/spec/aliases/absolute_path_spec.rb index 0bcdf85..3fb9d12 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.0 +if Puppet.version.to_f >= 4.5 describe 'test::absolute_path', type: :class do describe 'valid paths handling' do %w{ diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb new file mode 100644 index 0000000..aa435d7 --- /dev/null +++ b/spec/aliases/absolutepath_spec.rb @@ -0,0 +1,49 @@ +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 8bbb8b3..d0f9877 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.0 +if Puppet.version.to_f >= 4.5 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 f664457..78c57fc 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.0 +if Puppet.version.to_f >= 4.5 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 be31e43..cc20758 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.0 +if Puppet.version.to_f >= 4.5 describe 'test::float', type: :class do describe 'accepts floats' do [ diff --git a/spec/aliases/httpsurl_spec.rb b/spec/aliases/httpsurl_spec.rb new file mode 100644 index 0000000..97ae006 --- /dev/null +++ b/spec/aliases/httpsurl_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +if Puppet.version.to_f >= 4.5 + describe 'test::httpsurl', type: :class do + describe 'valid handling' do + %w{ + https://hello.com + https://notcreative.org + https://notexciting.co.uk + }.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' }, + { }, + '', + "httds://notquiteright.org", + "hptts:/nah", + "https;//notrightbutclose.org" + ].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 Stdlib::HTTPSUrl/) } + end + end + end + + end + end +end diff --git a/spec/aliases/httpurl_spec.rb b/spec/aliases/httpurl_spec.rb new file mode 100644 index 0000000..8bd57ca --- /dev/null +++ b/spec/aliases/httpurl_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +if Puppet.version.to_f >= 4.5 + describe 'test::httpurl', type: :class do + describe 'valid handling' do + %w{ + https://hello.com + https://notcreative.org + https://canstillaccepthttps.co.uk + http://anhttp.com + http://runningoutofideas.gov + http:// + }.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' }, + { }, + '', + "httds://notquiteright.org", + "hptts:/nah", + "https;//notrightbutclose.org" + ].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 Stdlib::HTTPUrl/) } + end + end + end + + end + end +end diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb index fbc8c19..260090a 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.0 +if Puppet.version.to_f >= 4.5 describe 'test::integer', type: :class do describe 'accepts integers' do [ diff --git a/spec/aliases/ip_address.rb b/spec/aliases/ip_address.rb index 036bfe5..664bf24 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.0 +if Puppet.version.to_f >= 4.5 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 640618c..e767b45 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.0 +if Puppet.version.to_f >= 4.5 describe 'test::ipv4', type: :class do describe 'accepts ipv4 addresses' do [ diff --git a/spec/aliases/ipv6_spec.rb b/spec/aliases/ipv6_spec.rb index 688eb16..13d7c3e 100644 --- a/spec/aliases/ipv6_spec.rb +++ b/spec/aliases/ipv6_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.0 +if Puppet.version.to_f >= 4.5 describe 'test::ipv6', type: :class do describe 'accepts ipv6 addresses' do [ diff --git a/spec/aliases/numeric_spec.rb b/spec/aliases/numeric_spec.rb index 9afe4ed..0e98bee 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.0 +if Puppet.version.to_f >= 4.5 describe 'test::numeric', type: :class do describe 'accepts numerics' do [ diff --git a/spec/aliases/string_spec.rb b/spec/aliases/string_spec.rb index 853b5af..8a93585 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.0 +if Puppet.version.to_f >= 4.5 describe 'test::string', type: :class do describe 'accepts strings' do [ diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb new file mode 100644 index 0000000..aee161d --- /dev/null +++ b/spec/aliases/unixpath_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +if Puppet.version.to_f >= 4.5 + 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 + }.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' }, + { }, + '', + "C:/whatever", + "\\var\\tmp", + "\\Users/hc/wksp/stdlib", + "*/Users//nope" + ].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 Stdlib::Unixpath/) } + end + end + end + + end + end +end diff --git a/spec/aliases/windowspath_spec.rb b/spec/aliases/windowspath_spec.rb new file mode 100644 index 0000000..c13794e --- /dev/null +++ b/spec/aliases/windowspath_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +if Puppet.version.to_f >= 4.5 + describe 'test::windowspath', type: :class do + describe 'valid handling' do + %w{ + C:\\ + C:\\WINDOWS\\System32 + C:/windows/system32 + X:/foo/bar + X:\\foo\\bar + \\\\host\\windows + }.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' }, + { }, + '', + "httds://notquiteright.org", + "/usr2/username/bin:/usr/local/bin:/usr/bin:.", + "C;//notright/here", + "C:noslashes" + ].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 Stdlib::Windowspath/) } + end + end + end + + end + end +end diff --git a/spec/fixtures/test/manifests/absolutepath.pp b/spec/fixtures/test/manifests/absolutepath.pp new file mode 100644 index 0000000..8321471 --- /dev/null +++ b/spec/fixtures/test/manifests/absolutepath.pp @@ -0,0 +1,6 @@ +# Class to test the Stdlib::Absolutepath type. Not to be confused with Stdlib::Compat::Absolute_path. +class test::absolutepath( + Stdlib::Absolutepath $value, + ) { + notice("Success") +} diff --git a/spec/fixtures/test/manifests/httpsurl.pp b/spec/fixtures/test/manifests/httpsurl.pp new file mode 100644 index 0000000..9d6b92d --- /dev/null +++ b/spec/fixtures/test/manifests/httpsurl.pp @@ -0,0 +1,6 @@ +# Class to test the Stdlib::HTTPSUrl type alias +class test::httpsurl( + Stdlib::HTTPSUrl $value, + ) { + notice("Success") +} diff --git a/spec/fixtures/test/manifests/httpurl.pp b/spec/fixtures/test/manifests/httpurl.pp new file mode 100644 index 0000000..abf869e --- /dev/null +++ b/spec/fixtures/test/manifests/httpurl.pp @@ -0,0 +1,6 @@ +# Class to test the Stdlib::HTTPUrl type alias +class test::httpurl( + Stdlib::HTTPUrl $value, + ) { + notice("Success") +} diff --git a/spec/fixtures/test/manifests/unixpath.pp b/spec/fixtures/test/manifests/unixpath.pp new file mode 100644 index 0000000..9311109 --- /dev/null +++ b/spec/fixtures/test/manifests/unixpath.pp @@ -0,0 +1,6 @@ +# Class to test the Stdlib::Unixpath type alias +class test::unixpath( + Stdlib::Unixpath $value, + ) { + notice("Success") +} diff --git a/spec/fixtures/test/manifests/windowspath.pp b/spec/fixtures/test/manifests/windowspath.pp new file mode 100644 index 0000000..af93ed3 --- /dev/null +++ b/spec/fixtures/test/manifests/windowspath.pp @@ -0,0 +1,6 @@ +# Class to test the Stdlib::Windowspath type alias +class test::windowspath( + Stdlib::Windowspath $value, + ) { + notice("Success") +} |