summaryrefslogtreecommitdiff
path: root/spec/acceptance/validate_string_spec.rb
diff options
context:
space:
mode:
authorDominic Cleal <dominic@cleal.org>2016-10-04 09:36:20 +0100
committerDominic Cleal <dominic@cleal.org>2016-10-04 09:57:25 +0100
commitcce67b42bb6d09d4e9773b64e28c07d8a93ed088 (patch)
tree3222c9b0969de0df0d28b8e423f16440243e11cc /spec/acceptance/validate_string_spec.rb
parent7228160175a17fb3d7f5b464553ef6c7791cf140 (diff)
Permit undef passed as `nil` to validate_string
When validate_string is called via the Puppet 4 deprecation wrappers from deprecation_gen (introduced in 970852d), `undef` is passed as `nil` where it was previously passed as `''` from the Puppet 3-style function API. This change explicitly permits a `nil` value in validate_string, and adds a test case to `is_string` which also accepts the same. Fixes test failures in apt, concat etc: Error while evaluating a Function Call, nil is not a string. It looks to be a NilClass at apt/manifests/source.pp:23:3 [..] # ./spec/fixtures/modules/stdlib/lib/puppet/parser/functions/validate_string.rb:34:in `block (2 levels) in <module:Functions>' # ./spec/fixtures/modules/stdlib/lib/puppet/parser/functions/validate_string.rb:32:in `each' # ./spec/fixtures/modules/stdlib/lib/puppet/parser/functions/validate_string.rb:32:in `block in <module:Functions>' # puppet-4.7.0/lib/puppet/parser/functions.rb:174:in `block (2 levels) in newfunction' # puppet-4.7.0/lib/puppet/util/profiler/around_profiler.rb:58:in `profile' # puppet-4.7.0/lib/puppet/util/profiler.rb:51:in `profile' # puppet-4.7.0/lib/puppet/parser/functions.rb:167:in `block in newfunction' # ./spec/fixtures/modules/stdlib/lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb:13:in `block (2 levels) in deprecation_gen'
Diffstat (limited to 'spec/acceptance/validate_string_spec.rb')
-rwxr-xr-xspec/acceptance/validate_string_spec.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/acceptance/validate_string_spec.rb b/spec/acceptance/validate_string_spec.rb
index 8956f48..ae3468f 100755
--- a/spec/acceptance/validate_string_spec.rb
+++ b/spec/acceptance/validate_string_spec.rb
@@ -20,6 +20,13 @@ describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(f
apply_manifest(pp, :catch_failures => true)
end
+ it 'validates undef' do
+ pp = <<-EOS
+ validate_string(undef)
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
it 'validates a non-string' do
{
%{validate_string({ 'a' => 'hash' })} => "Hash",