diff options
| -rw-r--r-- | lib/puppet/node/catalog.rb | 1 | ||||
| -rwxr-xr-x | spec/unit/node/catalog.rb | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb index 720b3752d..17927388a 100644 --- a/lib/puppet/node/catalog.rb +++ b/lib/puppet/node/catalog.rb @@ -95,6 +95,7 @@ class Puppet::Node::Catalog < Puppet::PGraph # isn't sufficient. return if newref == resource.ref if existing = @resource_table[newref] + return if existing == resource raise(ArgumentError, "Cannot alias %s to %s; resource %s already exists" % [resource.ref, name, newref]) end @resource_table[newref] = resource diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb index b4f1503da..45174e5e5 100755 --- a/spec/unit/node/catalog.rb +++ b/spec/unit/node/catalog.rb @@ -472,6 +472,11 @@ describe Puppet::Node::Catalog, " when functioning as a resource container" do @catalog.resource("me", "other").should equal(@one) end + it "should ignore conflicting aliases that point to the aliased resource" do + @catalog.alias(@one, "other") + lambda { @catalog.alias(@one, "other") }.should_not raise_error + end + it "should fail to add an alias if the aliased name already exists" do @catalog.add_resource @one proc { @catalog.alias @two, "one" }.should raise_error(ArgumentError) |
