summaryrefslogtreecommitdiff
path: root/spec/aliases
diff options
context:
space:
mode:
authorHelen Campbell <helen@puppetlabs.com>2016-10-06 14:22:13 +0100
committerHelen Campbell <helen@puppetlabs.com>2016-10-07 14:18:34 +0100
commit83539371e5b1e6ff412eda48c3a725653c506ece (patch)
treedf4613b9feab0048cefef62b941f62a2ae63f94b /spec/aliases
parent4aa519e998f2f4ce567bcaae5880800884a44bf6 (diff)
Addition of several new types
Diffstat (limited to 'spec/aliases')
-rw-r--r--spec/aliases/absolutepath_spec.rb49
-rw-r--r--spec/aliases/httpsurl_spec.rb40
-rw-r--r--spec/aliases/httpurl_spec.rb43
-rw-r--r--spec/aliases/unixpath_spec.rb41
-rw-r--r--spec/aliases/windowspath_spec.rb44
5 files changed, 217 insertions, 0 deletions
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/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/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