Skip to content

Instantly share code, notes, and snippets.

@domcleal
Created February 8, 2013 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domcleal/4738202 to your computer and use it in GitHub Desktop.
Save domcleal/4738202 to your computer and use it in GitHub Desktop.
commit 0e00d961d5e3fbd874eb542c9b346e7223b18d00
Author: Dominic Cleal <dcleal@redhat.com>
Date: Fri Feb 8 10:48:33 2013 +0000
Would have message gone
diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb
index ac46376..e232f37 100644
--- a/lib/puppet/transaction/event_manager.rb
+++ b/lib/puppet/transaction/event_manager.rb
@@ -90,7 +90,7 @@ class Puppet::Transaction::EventManager
def queued_events(resource)
return unless callbacks = @event_queues[resource]
callbacks.each do |callback, events|
- yield callback, events
+ yield callback, events unless events.empty?
end
end
diff --git a/spec/unit/transaction/event_manager_spec.rb b/spec/unit/transaction/event_manager_spec.rb
index d968be5..135490d 100755
--- a/spec/unit/transaction/event_manager_spec.rb
+++ b/spec/unit/transaction/event_manager_spec.rb
@@ -268,4 +268,36 @@ describe Puppet::Transaction::EventManager do
end
end
end
+
+ describe "when queueing then processing events for a given resource" do
+ before do
+ @transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
+ @manager = Puppet::Transaction::EventManager.new(@transaction)
+
+ @graph = stub 'graph', :matching_edges => [], :resource => @resource
+ @graph.stubs(:matching_edges).returns []
+ @manager.stubs(:relationship_graph).returns @graph
+
+ @resource = Puppet::Type.type(:file).new :path => make_absolute("/my/file")
+ @resource.expects(:self_refresh?).returns true
+ @resource.expects(:deleting?).returns false
+ @resource.expects(:info).with { |msg| msg.include?("Scheduling refresh") }
+ @event = Puppet::Transaction::Event.new(:name => :foo, :resource => @resource)
+ end
+
+ describe "and the events were dequeued/invalidated" do
+ before do
+ @event2 = Puppet::Transaction::Event.new(:name => :foo, :resource => @resource, :invalidate_refreshes => true)
+ @resource.expects(:info).with { |msg| msg.include?("Unscheduling") }
+ end
+
+ it "should not run an event or log" do
+ @resource.expects(:notice).with { |msg| msg.include?("Would have triggered 'refresh'") }.never
+ @resource.expects(:refresh).never
+
+ @manager.queue_events(@resource, [@event, @event2])
+ @manager.process_events(@resource)
+ end
+ end
+ end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment