diff options
author | Markus Roberts <Markus@reality.com> | 2010-04-15 16:30:32 -0700 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | cd06b877cd97edb26551d9c30c399d666603e586 (patch) | |
tree | 6476caed75f4e00d8a699727f006408ddf47b8b3 /spec/unit/parser | |
parent | 2de7da4fe3ad4a3821608141605829036ac5f1f8 (diff) | |
download | puppet-cd06b877cd97edb26551d9c30c399d666603e586.tar.gz puppet-cd06b877cd97edb26551d9c30c399d666603e586.tar.xz puppet-cd06b877cd97edb26551d9c30c399d666603e586.zip |
Fix for #3556 Plussignment value melding
The plussignment operator was constructing the new parameter value by
modifying the param object's value in place (so as to preserve the file
and line information for debugging). However, when multiple resources
are overridden by the same plussignment this would result in all of the
resources sharing the same value (the union of all the prior values and
the new value), which is wrong.
Instead, we need to give each resource its own copy of the value (e.g.,
a copy of the param object), which this patch implements.
Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-x | spec/unit/parser/resource.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb index 1af9da379..ca73bfb1a 100755 --- a/spec/unit/parser/resource.rb +++ b/spec/unit/parser/resource.rb @@ -401,6 +401,24 @@ describe Puppet::Parser::Resource do @resource[:testing].should == %w{other testing} end + it "should not merge parameter values when multiple resources are overriden with '+>' at once " do + @resource_2 = mkresource :source => @source + + @resource. set_parameter(:testing, "old_val_1") + @resource_2.set_parameter(:testing, "old_val_2") + + @source.stubs(:child_of?).returns true + param = Puppet::Parser::Resource::Param.new(:name => :testing, :value => "new_val", :source => @resource.source) + param.add = true + @override.set_parameter(param) + + @resource. merge(@override) + @resource_2.merge(@override) + + @resource [:testing].should == %w{old_val_1 new_val} + @resource_2[:testing].should == %w{old_val_2 new_val} + end + it "should promote tag overrides to real tags" do @source.stubs(:child_of?).returns true param = Puppet::Parser::Resource::Param.new(:name => :tag, :value => "testing", :source => @resource.source) |