summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortphoney <tp@puppet.com>2017-07-14 10:14:04 +0100
committertphoney <tp@puppet.com>2017-07-14 10:42:10 +0100
commit33922a4ec7a8c204a17e0c3017eea21faa220f39 (patch)
tree069c400254276e50176e5b11140c77f831590879
parent01d3004f0a6a1c662aea90edd5b1524139706c61 (diff)
FM-6239 clean up for puppet 5.tests/deprecation
-rw-r--r--lib/puppet/parser/functions/unique.rb4
-rw-r--r--spec/aliases/absolutepath_spec.rb2
-rw-r--r--spec/aliases/float_spec.rb2
-rw-r--r--spec/aliases/numeric_spec.rb2
-rw-r--r--spec/aliases/string_spec.rb2
-rwxr-xr-xspec/functions/deep_merge_spec.rb2
-rwxr-xr-xspec/functions/strftime_spec.rb4
-rwxr-xr-xspec/functions/unique_spec.rb46
8 files changed, 35 insertions, 29 deletions
diff --git a/lib/puppet/parser/functions/unique.rb b/lib/puppet/parser/functions/unique.rb
index b57431d..1e2a895 100644
--- a/lib/puppet/parser/functions/unique.rb
+++ b/lib/puppet/parser/functions/unique.rb
@@ -24,6 +24,10 @@ This returns:
EOS
) do |arguments|
+ if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0
+ function_deprecation([:unique, 'This method is deprecated, please use the core puppet unique function. There is further documentation for the function in the release notes of Puppet 5.0.'])
+ end
+
raise(Puppet::ParseError, "unique(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
value = arguments[0]
diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb
index cd442f2..ff23dc0 100644
--- a/spec/aliases/absolutepath_spec.rb
+++ b/spec/aliases/absolutepath_spec.rb
@@ -40,7 +40,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
].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/) }
+ it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for.*Variant/) }
end
end
end
diff --git a/spec/aliases/float_spec.rb b/spec/aliases/float_spec.rb
index 66079c6..84e1934 100644
--- a/spec/aliases/float_spec.rb
+++ b/spec/aliases/float_spec.rb
@@ -20,7 +20,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
[ 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/numeric_spec.rb b/spec/aliases/numeric_spec.rb
index bc17f4f..09c28ec 100644
--- a/spec/aliases/numeric_spec.rb
+++ b/spec/aliases/numeric_spec.rb
@@ -24,7 +24,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
[ 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 3ea1967..4fc8ce6 100644
--- a/spec/aliases/string_spec.rb
+++ b/spec/aliases/string_spec.rb
@@ -24,7 +24,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
].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 Undef or )?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/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb
index c91a07e..819e025 100755
--- a/spec/functions/deep_merge_spec.rb
+++ b/spec/functions/deep_merge_spec.rb
@@ -4,7 +4,7 @@ describe 'deep_merge' do
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it { is_expected.to run.with_params({ 'key' => 'value' }).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, /unexpected argument type String/) }
- it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) }
+ it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument/) }
it { is_expected.to run.with_params({}, '').and_return({}) }
it { is_expected.to run.with_params({}, {}).and_return({}) }
it { is_expected.to run.with_params({}, {}, {}).and_return({}) }
diff --git a/spec/functions/strftime_spec.rb b/spec/functions/strftime_spec.rb
index e76774a..41cda6a 100755
--- a/spec/functions/strftime_spec.rb
+++ b/spec/functions/strftime_spec.rb
@@ -14,9 +14,9 @@ describe 'strftime' do
expect(result.to_i).to(be > 1311953157)
end
- it "using %s should be lower then 1.5 trillion" do
+ it "using %s should be greater than 1.5 trillion" do
result = scope.function_strftime(["%s"])
- expect(result.to_i).to(be < 1500000000)
+ expect(result.to_i).to(be > 1500000000)
end
it "should return a date when given %Y-%m-%d" do
diff --git a/spec/functions/unique_spec.rb b/spec/functions/unique_spec.rb
index 7955acb..76932ec 100755
--- a/spec/functions/unique_spec.rb
+++ b/spec/functions/unique_spec.rb
@@ -1,29 +1,31 @@
require 'spec_helper'
describe 'unique' do
- describe 'signature validation' do
- it { is_expected.not_to eq(nil) }
- it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
- it {
- pending("Current implementation ignores parameters after the first.")
- is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
- }
- it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
- it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
- it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
- end
+ if Puppet.version.to_f < 5.0
+ describe 'signature validation' do
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+ it {
+ pending("Current implementation ignores parameters after the first.")
+ is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+ }
+ it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+ it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+ it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+ end
- context 'when called with an array' do
- it { is_expected.to run.with_params([]).and_return([]) }
- it { is_expected.to run.with_params(['a']).and_return(['a']) }
- it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) }
- it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) }
- end
+ context 'when called with an array' do
+ it { is_expected.to run.with_params([]).and_return([]) }
+ it { is_expected.to run.with_params(['a']).and_return(['a']) }
+ it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) }
+ it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) }
+ end
- context 'when called with a string' do
- it { is_expected.to run.with_params('').and_return('') }
- it { is_expected.to run.with_params('a').and_return('a') }
- it { is_expected.to run.with_params('aaba').and_return('ab') }
- it { is_expected.to run.with_params('ããъã').and_return('ãъ') }
+ context 'when called with a string' do
+ it { is_expected.to run.with_params('').and_return('') }
+ it { is_expected.to run.with_params('a').and_return('a') }
+ it { is_expected.to run.with_params('aaba').and_return('ab') }
+ it { is_expected.to run.with_params('ããъã').and_return('ãъ') }
+ end
end
end