We now only warn when there's an actual change to make, and we only make one warning per process run.
Signed-off-by: Luke Kanies <[email protected]> --- lib/puppet/type/file/owner.rb | 11 +++++++---- spec/unit/type/file/owner.rb | 14 ++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/puppet/type/file/owner.rb b/lib/puppet/type/file/owner.rb index 1dff59c..e5ca06a 100755 --- a/lib/puppet/type/file/owner.rb +++ b/lib/puppet/type/file/owner.rb @@ -28,10 +28,7 @@ module Puppet end def insync?(current) - unless Puppet::Util::SUIDManager.uid == 0 - warning "Cannot manage ownership unless running as root" - return true - end + return true unless should @should.each do |value| if value =~ /^\d+$/ @@ -44,6 +41,12 @@ module Puppet return true if uid == current end + + unless Puppet::Util::SUIDManager.uid == 0 + warnonce "Cannot manage ownership unless running as root" + return true + end + return false end diff --git a/spec/unit/type/file/owner.rb b/spec/unit/type/file/owner.rb index 1ea01cb..62f7b0a 100755 --- a/spec/unit/type/file/owner.rb +++ b/spec/unit/type/file/owner.rb @@ -55,11 +55,13 @@ describe property do describe "when determining if the file is in sync" do describe "and not running as root" do - it "should warn and return true" do - @owner.should = 10 + it "should warn once and return true" do Puppet::Util::SUIDManager.expects(:uid).returns 1 - @owner.expects(:warning) - @owner.must be_insync("whatever") + + @owner.expects(:warnonce) + + @owner.should = [10] + @owner.must be_insync(20) end end @@ -67,6 +69,10 @@ describe property do Puppet::Util::SUIDManager.stubs(:uid).returns 0 end + it "should be in sync if 'should' is not provided" do + @owner.must be_insync(10) + end + it "should directly compare the owner values if the desired owner is an integer" do @owner.should = [10] @owner.must be_insync(10) -- 1.6.1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
