diff options
-rw-r--r-- | lib/puppet/resource/status.rb | 2 | ||||
-rw-r--r-- | lib/puppet/transaction/event.rb | 1 | ||||
-rwxr-xr-x | spec/unit/resource/status_spec.rb | 8 | ||||
-rwxr-xr-x | spec/unit/transaction/event_spec.rb | 8 | ||||
-rwxr-xr-x | spec/unit/transaction/resource_harness_spec.rb | 6 |
5 files changed, 17 insertions, 8 deletions
diff --git a/lib/puppet/resource/status.rb b/lib/puppet/resource/status.rb index 43d3f1644..b138c6520 100644 --- a/lib/puppet/resource/status.rb +++ b/lib/puppet/resource/status.rb @@ -47,6 +47,8 @@ module Puppet @resource = resource.to_s @change_count = 0 @out_of_sync_count = 0 + @changed = false + @out_of_sync = false [:file, :line].each do |attr| send(attr.to_s + "=", resource.send(attr)) diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb index e3537bb08..b9fa5c38b 100644 --- a/lib/puppet/transaction/event.rb +++ b/lib/puppet/transaction/event.rb @@ -16,6 +16,7 @@ class Puppet::Transaction::Event EVENT_STATUSES = %w{noop success failure audit} def initialize(*args) + @audited = false options = args.last.is_a?(Hash) ? args.pop : ATTRIBUTES.inject({}) { |hash, attr| hash[attr] = args.pop; hash } options.each { |attr, value| send(attr.to_s + "=", value) unless value.nil? } diff --git a/spec/unit/resource/status_spec.rb b/spec/unit/resource/status_spec.rb index 22d5fb4f9..3d9a84152 100755 --- a/spec/unit/resource/status_spec.rb +++ b/spec/unit/resource/status_spec.rb @@ -112,20 +112,20 @@ describe Puppet::Resource::Status do it "should not start with any changes" do @status.change_count.should == 0 - @status.changed.should be_false - @status.out_of_sync.should be_false + @status.changed.should == false + @status.out_of_sync.should == 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 + @status.changed.should == 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 + @status.out_of_sync.should == false end ['failure', 'noop', 'success'].each do |event_status| diff --git a/spec/unit/transaction/event_spec.rb b/spec/unit/transaction/event_spec.rb index 4a3e6bad5..2776be8d7 100755 --- a/spec/unit/transaction/event_spec.rb +++ b/spec/unit/transaction/event_spec.rb @@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/transaction/event' describe Puppet::Transaction::Event do - [:previous_value, :desired_value, :property, :resource, :name, :message, :file, :line, :tags].each do |attr| + [:previous_value, :desired_value, :property, :resource, :name, :message, :file, :line, :tags, :audited].each do |attr| it "should support #{attr}" do event = Puppet::Transaction::Event.new event.send(attr.to_s + "=", "foo") @@ -46,6 +46,12 @@ describe Puppet::Transaction::Event do Puppet::Transaction::Event.new.time.should be_instance_of(Time) end + describe "audit property" do + it "should default to false" do + Puppet::Transaction::Event.new.audited.should == false + end + end + describe "when sending logs" do before do Puppet::Util::Log.stubs(:new) diff --git a/spec/unit/transaction/resource_harness_spec.rb b/spec/unit/transaction/resource_harness_spec.rb index 387deca61..771c7b4b0 100755 --- a/spec/unit/transaction/resource_harness_spec.rb +++ b/spec/unit/transaction/resource_harness_spec.rb @@ -208,11 +208,11 @@ describe Puppet::Transaction::ResourceHarness do status.out_of_sync_count.should == expected_out_of_sync_count # Check legacy summary fields - status.changed.should == (expected_change_count == 0 ? nil : true) - status.out_of_sync.should == (expected_out_of_sync_count == 0 ? nil : true) + status.changed.should == (expected_change_count != 0) + status.out_of_sync.should == (expected_out_of_sync_count != 0) # Check the :synced field on state.yml - synced_should_be_set = !noop_mode && status.changed != nil + synced_should_be_set = !noop_mode && status.changed (@harness.cached(resource, :synced) != nil).should == synced_should_be_set end; end end |