From 4d3030c6dd67dcb1f6116e7e3d09ddcd20ee726b Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Thu, 16 Dec 2010 16:23:34 -0800 Subject: Modified the behavior of Puppet::Resource::Status as follows: - #change_count now only counts events that represent successful changes. It does not count failures, audits, or noops. - #changed is equivalent to #change_count > 0. - #out_of_sync_count (a new attribute) counts all events except audits. - #out_of_sync is equivalent to #out_of_sync_count > 0. This should hopefully make the summary statistics in reports more useful. --- spec/unit/resource/status_spec.rb | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'spec/unit/resource') diff --git a/spec/unit/resource/status_spec.rb b/spec/unit/resource/status_spec.rb index 7a21164c3..bda8aea00 100755 --- a/spec/unit/resource/status_spec.rb +++ b/spec/unit/resource/status_spec.rb @@ -101,8 +101,8 @@ describe Puppet::Resource::Status do @status.events.should == [event] end - it "should count the number of events and set changed" do - 3.times{ @status << Puppet::Transaction::Event.new } + it "should count the number of successful events and set changed" do + 3.times{ @status << Puppet::Transaction::Event.new(:status => 'success') } @status.change_count.should == 3 @status.changed.should == true @@ -115,4 +115,24 @@ describe Puppet::Resource::Status do @status.changed.should be_false @status.out_of_sync.should be_false end + + it "should not treat failure, audit, or noop events as changed" do + ['failure', 'audit', 'noop'].each do |s| @status << Puppet::Transaction::Event.new(:status => s) end + @status.change_count.should == 0 + @status.changed.should be_false + end + + it "should not treat audit events as out of sync" do + @status << Puppet::Transaction::Event.new(:status => 'audit') + @status.out_of_sync_count.should == 0 + @status.out_of_sync.should be_false + end + + ['failure', 'noop', 'success'].each do |event_status| + it "should treat #{event_status} events as out of sync" do + 3.times do @status << Puppet::Transaction::Event.new(:status => event_status) end + @status.out_of_sync_count.should == 3 + @status.out_of_sync.should == true + end + end end -- cgit