summaryrefslogtreecommitdiff
path: root/spec/unit/resource/status_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/resource/status_spec.rb')
-rwxr-xr-xspec/unit/resource/status_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/unit/resource/status_spec.rb b/spec/unit/resource/status_spec.rb
index 115b112cc..f3cc5699c 100755
--- a/spec/unit/resource/status_spec.rb
+++ b/spec/unit/resource/status_spec.rb
@@ -8,6 +8,8 @@ describe Puppet::Resource::Status do
before do
@resource = Puppet::Type.type(:file).new :path => make_absolute("/my/file")
+ @containment_path = ["foo", "bar", "baz"]
+ @resource.stubs(:pathbuilder).returns @containment_path
@status = Puppet::Resource::Status.new(@resource)
end
@@ -44,6 +46,10 @@ describe Puppet::Resource::Status do
Puppet::Resource::Status.new(@resource).source_description.should == "/my/path"
end
+ it "should set its containment path" do
+ Puppet::Resource::Status.new(@resource).containment_path.should == @containment_path
+ end
+
[:file, :line].each do |attr|
it "should copy the resource's #{attr}" do
@resource.expects(attr).returns "foo"
@@ -151,4 +157,54 @@ describe Puppet::Resource::Status do
@status.to_yaml_properties.should =~ Puppet::Resource::Status::YAML_ATTRIBUTES
end
end
+
+ it "should round trip through pson" do
+ @status.file = "/foo.rb"
+ @status.line = 27
+ @status.evaluation_time = 2.7
+ @status.tags = %w{one two}
+ @status << Puppet::Transaction::Event.new(:name => :mode_changed, :status => 'audit')
+ @status.failed = false
+ @status.changed = true
+ @status.out_of_sync = true
+ @status.skipped = false
+
+ @status.containment_path.should == @containment_path
+
+ tripped = Puppet::Resource::Status.from_pson(PSON.parse(@status.to_pson))
+
+ tripped.title.should == @status.title
+ tripped.containment_path.should == @status.containment_path
+ tripped.file.should == @status.file
+ tripped.line.should == @status.line
+ tripped.resource.should == @status.resource
+ tripped.resource_type.should == @status.resource_type
+ tripped.evaluation_time.should == @status.evaluation_time
+ tripped.tags.should == @status.tags
+ tripped.time.should == @status.time
+ tripped.failed.should == @status.failed
+ tripped.changed.should == @status.changed
+ tripped.out_of_sync.should == @status.out_of_sync
+ tripped.skipped.should == @status.skipped
+
+ tripped.change_count.should == @status.change_count
+ tripped.out_of_sync_count.should == @status.out_of_sync_count
+ events_as_hashes(tripped).should == events_as_hashes(@status)
+ end
+
+ def events_as_hashes(report)
+ report.events.collect do |e|
+ {
+ :audited => e.audited,
+ :property => e.property,
+ :previous_value => e.previous_value,
+ :desired_value => e.desired_value,
+ :historical_value => e.historical_value,
+ :message => e.message,
+ :name => e.name,
+ :status => e.status,
+ :time => e.time,
+ }
+ end
+ end
end