summaryrefslogtreecommitdiffstats
path: root/spec/unit/application
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-12-28 17:18:55 -0800
committerJesse Wolfe <jes5199@gmail.com>2011-01-03 11:30:02 -0800
commit06a8d1ee8775ba8693ced002f5972bbfc346ebf8 (patch)
tree7c91aeb9a4055af0de5d6cd884de9540941e9927 /spec/unit/application
parent4664460e0a4a935dab814a3218fc054c13e3cab6 (diff)
downloadpuppet-06a8d1ee8775ba8693ced002f5972bbfc346ebf8.tar.gz
puppet-06a8d1ee8775ba8693ced002f5972bbfc346ebf8.tar.xz
puppet-06a8d1ee8775ba8693ced002f5972bbfc346ebf8.zip
Fix #5698 puppet inspect shouldn't report of attributes of deleted files
If a resource is absent, then reporting that its properties are all ":absent" is not particularly correct. This patch makes the `inspect` application's reports behave more like `apply` reports, and skip properties other than :ensure for absent resources. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'spec/unit/application')
-rw-r--r--spec/unit/application/inspect_spec.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb
index a3cc74d86..b931708c3 100644
--- a/spec/unit/application/inspect_spec.rb
+++ b/spec/unit/application/inspect_spec.rb
@@ -51,7 +51,7 @@ describe Puppet::Application::Inspect do
catalog = Puppet::Resource::Catalog.new
file = Tempfile.new("foo")
file.puts("file contents")
- file.flush
+ file.close
resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"})
catalog.add_resource(resource)
Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog)
@@ -69,6 +69,29 @@ describe Puppet::Application::Inspect do
end
properties["ensure"].should == :file
properties["content"].should == "{md5}#{Digest::MD5.hexdigest("file contents\n")}"
+ properties.has_key?("target").should == false
+ end
+
+ it "should not report irrelevent attributes if the resource is absent" do
+ catalog = Puppet::Resource::Catalog.new
+ file = Tempfile.new("foo")
+ resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"})
+ file.delete
+ catalog.add_resource(resource)
+ Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog)
+
+ events = nil
+
+ Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request|
+ events = request.instance.resource_statuses.values.first.events
+ end
+
+ @inspect.run_command
+
+ properties = events.inject({}) do |property_values, event|
+ property_values.merge(event.property => event.previous_value)
+ end
+ properties.should == {"ensure" => :absent}
end
end