summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/functions/validate_hash.rb2
-rw-r--r--lib/puppet/parser/functions/validate_slength.rb2
-rwxr-xr-xspec/functions/validate_hash_spec.rb12
-rwxr-xr-xspec/functions/validate_slength_spec.rb11
4 files changed, 27 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/validate_hash.rb b/lib/puppet/parser/functions/validate_hash.rb
index 9bdd543..800a758 100644
--- a/lib/puppet/parser/functions/validate_hash.rb
+++ b/lib/puppet/parser/functions/validate_hash.rb
@@ -18,6 +18,8 @@ module Puppet::Parser::Functions
ENDHEREDOC
+ function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.'])
+
unless args.length > 0 then
raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)")
end
diff --git a/lib/puppet/parser/functions/validate_slength.rb b/lib/puppet/parser/functions/validate_slength.rb
index 47c7d4a..1641e5a 100644
--- a/lib/puppet/parser/functions/validate_slength.rb
+++ b/lib/puppet/parser/functions/validate_slength.rb
@@ -21,6 +21,8 @@ module Puppet::Parser::Functions
ENDHEREDOC
+ function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String[x]. There is further documentation for validate_legacy function in the README.'])
+
raise Puppet::ParseError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 or args.length == 3
input, max_length, min_length = *args
diff --git a/spec/functions/validate_hash_spec.rb b/spec/functions/validate_hash_spec.rb
index 2e8e59f..7b118e2 100755
--- a/spec/functions/validate_hash_spec.rb
+++ b/spec/functions/validate_hash_spec.rb
@@ -5,6 +5,18 @@ describe 'validate_hash' 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) }
+ describe 'check for deprecation warning' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+ # Checking for deprecation warning
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params({'key' => 'value'})
+ end
+ end
+
describe 'valid inputs' do
it { is_expected.to run.with_params({}) }
it { is_expected.to run.with_params({'key' => 'value'}) }
diff --git a/spec/functions/validate_slength_spec.rb b/spec/functions/validate_slength_spec.rb
index 5a8fa6a..2ea253c 100755
--- a/spec/functions/validate_slength_spec.rb
+++ b/spec/functions/validate_slength_spec.rb
@@ -1,6 +1,17 @@
require 'spec_helper'
describe 'validate_slength' do
+ after(:context) do
+ ENV.delete('STDLIB_LOG_DEPRECATIONS')
+ end
+
+ # Checking for deprecation warning
+ it 'should display a single deprecation' do
+ ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
+ scope.expects(:warning).with(includes('This method is deprecated'))
+ is_expected.to run.with_params('1234567890', 10)
+ end
+
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) }