Skip to content

Commit 1ab94ba

Browse files
author
Helen Campbell
committed
Add deprecation warnings to remaining validates
1 parent 0ec7ffa commit 1ab94ba

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

lib/puppet/parser/functions/validate_hash.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module Puppet::Parser::Functions
1818
1919
ENDHEREDOC
2020

21+
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_leg acy function in the README.'])
22+
2123
unless args.length > 0 then
2224
raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)")
2325
end

lib/puppet/parser/functions/validate_slength.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module Puppet::Parser::Functions
2121
2222
ENDHEREDOC
2323

24+
function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdl ib validate_legacy function, with Stdlib::Compat::String[x]. There is further documentation for validate_legacy function in the README.'])
25+
2426
raise Puppet::ParseError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 or args.length == 3
2527

2628
input, max_length, min_length = *args

spec/functions/validate_hash_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
it { is_expected.not_to eq(nil) }
66
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
77

8+
describe 'check for deprecation warning' do
9+
after(:context) do
10+
ENV.delete('STDLIB_LOG_DEPRECATIONS')
11+
end
12+
# Checking for deprecation warning
13+
it 'should display a single deprecation' do
14+
ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
15+
scope.expects(:warning).with(includes('This method is deprecated'))
16+
is_expected.to run.with_params({'key' => 'value'})
17+
end
18+
end
19+
820
describe 'valid inputs' do
921
it { is_expected.to run.with_params({}) }
1022
it { is_expected.to run.with_params({'key' => 'value'}) }

spec/functions/validate_slength_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
require 'spec_helper'
22

33
describe 'validate_slength' do
4+
after(:context) do
5+
ENV.delete('STDLIB_LOG_DEPRECATIONS')
6+
end
7+
8+
# Checking for deprecation warning
9+
it 'should display a single deprecation' do
10+
ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
11+
scope.expects(:warning).with(includes('This method is deprecated'))
12+
is_expected.to run.with_params('1234567890', 10)
13+
end
14+
415
describe 'signature validation' do
516
it { is_expected.not_to eq(nil) }
617
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }

0 commit comments

Comments
 (0)