From 999c267a3871c7d59513869c94c43c3477f1c6f1 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Wed, 10 Aug 2016 14:17:16 +0100 Subject: (MAINT) move test fixture to proper location --- spec/fixtures/modules/test/manifests/absolute_path.pp | 6 ------ spec/fixtures/modules/test/manifests/array.pp | 8 -------- spec/fixtures/modules/test/manifests/bool.pp | 8 -------- spec/fixtures/modules/test/manifests/float.pp | 8 -------- spec/fixtures/modules/test/manifests/integer.pp | 8 -------- spec/fixtures/modules/test/manifests/numeric.pp | 8 -------- spec/fixtures/modules/test/manifests/string.pp | 8 -------- spec/fixtures/test/manifests/absolute_path.pp | 6 ++++++ spec/fixtures/test/manifests/array.pp | 8 ++++++++ spec/fixtures/test/manifests/bool.pp | 8 ++++++++ spec/fixtures/test/manifests/float.pp | 8 ++++++++ spec/fixtures/test/manifests/integer.pp | 8 ++++++++ spec/fixtures/test/manifests/numeric.pp | 8 ++++++++ spec/fixtures/test/manifests/string.pp | 8 ++++++++ 14 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 spec/fixtures/modules/test/manifests/absolute_path.pp delete mode 100644 spec/fixtures/modules/test/manifests/array.pp delete mode 100644 spec/fixtures/modules/test/manifests/bool.pp delete mode 100644 spec/fixtures/modules/test/manifests/float.pp delete mode 100644 spec/fixtures/modules/test/manifests/integer.pp delete mode 100644 spec/fixtures/modules/test/manifests/numeric.pp delete mode 100644 spec/fixtures/modules/test/manifests/string.pp create mode 100644 spec/fixtures/test/manifests/absolute_path.pp create mode 100644 spec/fixtures/test/manifests/array.pp create mode 100644 spec/fixtures/test/manifests/bool.pp create mode 100644 spec/fixtures/test/manifests/float.pp create mode 100644 spec/fixtures/test/manifests/integer.pp create mode 100644 spec/fixtures/test/manifests/numeric.pp create mode 100644 spec/fixtures/test/manifests/string.pp (limited to 'spec') diff --git a/spec/fixtures/modules/test/manifests/absolute_path.pp b/spec/fixtures/modules/test/manifests/absolute_path.pp deleted file mode 100644 index d77f6bd..0000000 --- a/spec/fixtures/modules/test/manifests/absolute_path.pp +++ /dev/null @@ -1,6 +0,0 @@ -# Class to test the Stdlib::Compat::Absolute_path type alias -class test::absolute_path( - Stdlib::Compat::Absolute_path $value, - ) { - notice("Success") -} diff --git a/spec/fixtures/modules/test/manifests/array.pp b/spec/fixtures/modules/test/manifests/array.pp deleted file mode 100644 index 84b6a5b..0000000 --- a/spec/fixtures/modules/test/manifests/array.pp +++ /dev/null @@ -1,8 +0,0 @@ -# Class to test the Stdlib::Compat::Array type alias -class test::array( - Stdlib::Compat::Array $value, - ) { - - notice("Success") - -} diff --git a/spec/fixtures/modules/test/manifests/bool.pp b/spec/fixtures/modules/test/manifests/bool.pp deleted file mode 100644 index ab5b5ea..0000000 --- a/spec/fixtures/modules/test/manifests/bool.pp +++ /dev/null @@ -1,8 +0,0 @@ -# Class to test the Stdlib::Compat::Bool type alias -class test::bool( - Stdlib::Compat::Bool $value, - ) { - - notice("Success") - -} diff --git a/spec/fixtures/modules/test/manifests/float.pp b/spec/fixtures/modules/test/manifests/float.pp deleted file mode 100644 index 03a603d..0000000 --- a/spec/fixtures/modules/test/manifests/float.pp +++ /dev/null @@ -1,8 +0,0 @@ -# Class to test the Stdlib::Compat::Float type alias -class test::float( - Stdlib::Compat::Float $value, - ) { - - notice("Success") - -} diff --git a/spec/fixtures/modules/test/manifests/integer.pp b/spec/fixtures/modules/test/manifests/integer.pp deleted file mode 100644 index a4f26df..0000000 --- a/spec/fixtures/modules/test/manifests/integer.pp +++ /dev/null @@ -1,8 +0,0 @@ -# Class to test the Stdlib::Compat::Integer type alias -class test::integer( - Stdlib::Compat::Integer $value, - ) { - - notice("Success") - -} diff --git a/spec/fixtures/modules/test/manifests/numeric.pp b/spec/fixtures/modules/test/manifests/numeric.pp deleted file mode 100644 index 2657ebc..0000000 --- a/spec/fixtures/modules/test/manifests/numeric.pp +++ /dev/null @@ -1,8 +0,0 @@ -# Class to test the Stdlib::Compat::Numeric type alias -class test::numeric( - Stdlib::Compat::Numeric $value, - ) { - - notice("Success") - -} diff --git a/spec/fixtures/modules/test/manifests/string.pp b/spec/fixtures/modules/test/manifests/string.pp deleted file mode 100644 index 6508c70..0000000 --- a/spec/fixtures/modules/test/manifests/string.pp +++ /dev/null @@ -1,8 +0,0 @@ -# Class to test the Stdlib::Compat::String type alias -class test::string( - Stdlib::Compat::String $value, - ) { - - notice("Success") - -} diff --git a/spec/fixtures/test/manifests/absolute_path.pp b/spec/fixtures/test/manifests/absolute_path.pp new file mode 100644 index 0000000..d77f6bd --- /dev/null +++ b/spec/fixtures/test/manifests/absolute_path.pp @@ -0,0 +1,6 @@ +# Class to test the Stdlib::Compat::Absolute_path type alias +class test::absolute_path( + Stdlib::Compat::Absolute_path $value, + ) { + notice("Success") +} diff --git a/spec/fixtures/test/manifests/array.pp b/spec/fixtures/test/manifests/array.pp new file mode 100644 index 0000000..84b6a5b --- /dev/null +++ b/spec/fixtures/test/manifests/array.pp @@ -0,0 +1,8 @@ +# Class to test the Stdlib::Compat::Array type alias +class test::array( + Stdlib::Compat::Array $value, + ) { + + notice("Success") + +} diff --git a/spec/fixtures/test/manifests/bool.pp b/spec/fixtures/test/manifests/bool.pp new file mode 100644 index 0000000..ab5b5ea --- /dev/null +++ b/spec/fixtures/test/manifests/bool.pp @@ -0,0 +1,8 @@ +# Class to test the Stdlib::Compat::Bool type alias +class test::bool( + Stdlib::Compat::Bool $value, + ) { + + notice("Success") + +} diff --git a/spec/fixtures/test/manifests/float.pp b/spec/fixtures/test/manifests/float.pp new file mode 100644 index 0000000..03a603d --- /dev/null +++ b/spec/fixtures/test/manifests/float.pp @@ -0,0 +1,8 @@ +# Class to test the Stdlib::Compat::Float type alias +class test::float( + Stdlib::Compat::Float $value, + ) { + + notice("Success") + +} diff --git a/spec/fixtures/test/manifests/integer.pp b/spec/fixtures/test/manifests/integer.pp new file mode 100644 index 0000000..a4f26df --- /dev/null +++ b/spec/fixtures/test/manifests/integer.pp @@ -0,0 +1,8 @@ +# Class to test the Stdlib::Compat::Integer type alias +class test::integer( + Stdlib::Compat::Integer $value, + ) { + + notice("Success") + +} diff --git a/spec/fixtures/test/manifests/numeric.pp b/spec/fixtures/test/manifests/numeric.pp new file mode 100644 index 0000000..2657ebc --- /dev/null +++ b/spec/fixtures/test/manifests/numeric.pp @@ -0,0 +1,8 @@ +# Class to test the Stdlib::Compat::Numeric type alias +class test::numeric( + Stdlib::Compat::Numeric $value, + ) { + + notice("Success") + +} diff --git a/spec/fixtures/test/manifests/string.pp b/spec/fixtures/test/manifests/string.pp new file mode 100644 index 0000000..6508c70 --- /dev/null +++ b/spec/fixtures/test/manifests/string.pp @@ -0,0 +1,8 @@ +# Class to test the Stdlib::Compat::String type alias +class test::string( + Stdlib::Compat::String $value, + ) { + + notice("Success") + +} -- cgit v1.2.3 From adf922c28441bc95f5cbac1f0951256c080b3298 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Wed, 10 Aug 2016 14:17:16 +0100 Subject: (WIP) Addition of validate legacy function --- spec/classes/validate_legacy_spec.rb | 39 +++++++++++++++++++++++++ spec/fixtures/test/manifests/validate_legacy.pp | 18 ++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 spec/classes/validate_legacy_spec.rb create mode 100644 spec/fixtures/test/manifests/validate_legacy.pp (limited to 'spec') diff --git a/spec/classes/validate_legacy_spec.rb b/spec/classes/validate_legacy_spec.rb new file mode 100644 index 0000000..ded6890 --- /dev/null +++ b/spec/classes/validate_legacy_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +if Puppet.version.to_f >= 4.0 + # validate_legacy requires a proper scope to run, so we have to trigger a true compilation here, + # instead of being able to leverage the function test group. + describe 'test::validate_legacy', type: :class do + + describe 'validate_legacy passes assertion of type but not previous validation' do + let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: 5, previous_arg1: ["^\\d+$", ""] }} + it { + Puppet.expects(:warn).with(includes('Accepting previously invalid value for target_type')) + is_expected.to compile + } + end + + describe 'validate_legacy passes assertion of type and previous validation' do + let(:params) {{ type: "Optional[String]", prev_validation: "validate_re", value: "5", previous_arg1: ["."] }} + it { is_expected.to compile } + end + + describe 'validate_legacy fails assertion of type and passes previous validation' do + let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_arg1: ["."] }} + it { + Puppet.expects(:warn).with(includes('expected')) + is_expected.to compile + } + end + + describe 'validate_legacy fails assertion and fails previous validation' do + let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_arg1: ["thisisnotright"] }} + it { is_expected.to compile.and_raise_error(/Error while evaluating a Function Call, \w* expected an \w* value, got \w*/) } + end + + describe 'validate_legacy works with multi-argument validate_ functions' do + let(:params) {{ type: "Integer", prev_validation: "validate_integer", value: 10, previous_arg1: 100, previous_arg2: 0 }} + it { is_expected.to compile } + end + end +end diff --git a/spec/fixtures/test/manifests/validate_legacy.pp b/spec/fixtures/test/manifests/validate_legacy.pp new file mode 100644 index 0000000..706df88 --- /dev/null +++ b/spec/fixtures/test/manifests/validate_legacy.pp @@ -0,0 +1,18 @@ +# Class to test stdlib validate_legacy function + +class test::validate_legacy( + $type, + $prev_validation, + $value, + $previous_arg1, + $previous_arg2 = undef, + ) { + + if $previous_arg2 == undef { + validate_legacy( $type, $prev_validation, $value, $previous_arg1 ) + } else { + validate_legacy( $type, $prev_validation, $value, $previous_arg1, $previous_arg2 ) + } + notice("Success") + +} -- cgit v1.2.3