diff options
-rw-r--r-- | lib/puppet/node/catalog.rb | 2 | ||||
-rwxr-xr-x | spec/unit/node/catalog.rb | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb index 852904967..39b3fdfdc 100644 --- a/lib/puppet/node/catalog.rb +++ b/lib/puppet/node/catalog.rb @@ -68,6 +68,7 @@ class Puppet::Node::Catalog < Puppet::PGraph ref = resource.ref + @transient_resources << resource if applying? @resource_table[ref] = resource # If the name and title differ, set up an alias @@ -199,7 +200,6 @@ class Puppet::Node::Catalog < Puppet::PGraph end return unless resource = klass.create(options) - @transient_resources << resource if applying? add_resource(resource) if @relationship_graph @relationship_graph.add_resource(resource) unless @relationship_graph.resource(resource.ref) diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb index c986fc24e..68b8af347 100755 --- a/spec/unit/node/catalog.rb +++ b/spec/unit/node/catalog.rb @@ -784,6 +784,20 @@ describe Puppet::Node::Catalog, " when creating a relationship graph" do @catalog.resource("File[/yay]").should be_nil end + it "should remove resources added mid-transaction" do + @transaction = mock 'transaction' + Puppet::Transaction.stubs(:new).returns(@transaction) + @transaction.stubs(:evaluate) + @transaction.stubs(:cleanup) + @transaction.stubs(:addtimes) + file = Puppet::Type.type(:file).create(:name => "/yay", :ensure => :file) + @catalog.apply do |trans| + @catalog.add_resource file + @catalog.resource("File[/yay]").should_not be_nil + end + @catalog.resource("File[/yay]").should be_nil + end + it "should remove resources from the relationship graph if it exists" do @catalog.remove_resource(@one) @catalog.relationship_graph.vertex?(@one).should be_false |