Skip to content

(MODULES-3246) Fix concat with Hash arguments. #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/concat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Puppet::Parser::Functions
arguments.shift

arguments.each do |x|
result = result + Array(x)
result = result + (x.is_a?(Array) ? x : [x])
end

return result
Expand Down
14 changes: 14 additions & 0 deletions spec/acceptance/concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
}
EOS

apply_manifest(pp, :catch_failures => true)
end
it 'should concat hash arguments' do
pp = <<-EOS
$output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
validate_array($output)
if size($output) != 2 {
fail("${output} should have 2 elements.")
}
if $output[1] != {"c" => "d", "e" => "f"} {
fail("${output} does not have the expected hash for the second element.")
}
EOS

apply_manifest(pp, :catch_failures => true)
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/functions/concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
it { is_expected.to run.with_params(['1','2','3'],[['4','5'],'6']).and_return(['1','2','3',['4','5'],'6']) }
it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) }
it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) }
it { is_expected.to run.with_params([{"a" => "b"}], {"c" => "d", "e" => "f"}).and_return([{"a" => "b"}, {"c" => "d", "e" => "f"}]) }

it "should leave the original array intact" do
argument1 = ['1','2','3']
Expand Down