summaryrefslogtreecommitdiffstats
path: root/spec/unit/resource
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-01-05 17:22:30 -0800
committerNick Lewis <nick@puppetlabs.com>2011-01-06 15:19:42 -0800
commitb16e10dba6606b808ef195f4b57f2e8c66cf65ab (patch)
treebdacf054c1e877166217336322050ee03f28d607 /spec/unit/resource
parentfb8509acbd947712cac094a49227d28a16a366aa (diff)
parent19eb1e78e115d10bfb822e510213e4fab9cd2599 (diff)
downloadpuppet-b16e10dba6606b808ef195f4b57f2e8c66cf65ab.tar.gz
puppet-b16e10dba6606b808ef195f4b57f2e8c66cf65ab.tar.xz
puppet-b16e10dba6606b808ef195f4b57f2e8c66cf65ab.zip
Merge branch '2.6.x' into next
Conflicts: Rakefile lib/puppet/resource/type_collection.rb lib/puppet/simple_graph.rb lib/puppet/transaction.rb lib/puppet/transaction/report.rb lib/puppet/util/metric.rb spec/integration/indirector/report/rest_spec.rb spec/spec_specs/runnable_spec.rb spec/unit/configurer_spec.rb spec/unit/indirector_spec.rb spec/unit/transaction/change_spec.rb
Diffstat (limited to 'spec/unit/resource')
-rwxr-xr-xspec/unit/resource/catalog_spec.rb8
-rwxr-xr-xspec/unit/resource/status_spec.rb56
2 files changed, 55 insertions, 9 deletions
diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb
index 1af48a5c9..42850c23b 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -874,9 +874,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
end
end
-describe Puppet::Resource::Catalog, "when converting to pson" do
- confine "Missing 'pson' library" => Puppet.features.pson?
-
+describe Puppet::Resource::Catalog, "when converting to pson", :if => Puppet.features.pson? do
before do
@catalog = Puppet::Resource::Catalog.new("myhost")
end
@@ -934,9 +932,7 @@ describe Puppet::Resource::Catalog, "when converting to pson" do
end
end
-describe Puppet::Resource::Catalog, "when converting from pson" do
- confine "Missing 'pson' library" => Puppet.features.pson?
-
+describe Puppet::Resource::Catalog, "when converting from pson", :if => Puppet.features.pson? do
def pson_result_should
Puppet::Resource::Catalog.expects(:new).with { |hash| yield hash }
end
diff --git a/spec/unit/resource/status_spec.rb b/spec/unit/resource/status_spec.rb
index ce83e5d47..343b8d318 100755
--- a/spec/unit/resource/status_spec.rb
+++ b/spec/unit/resource/status_spec.rb
@@ -10,7 +10,12 @@ describe Puppet::Resource::Status do
@status = Puppet::Resource::Status.new(@resource)
end
- [:node, :version, :file, :line, :current_values, :skipped_reason, :status, :evaluation_time, :change_count].each do |attr|
+ it "should compute type and title correctly" do
+ @status.resource_type.should == "File"
+ @status.title.should == "/my/file"
+ end
+
+ [:node, :file, :line, :current_values, :status, :evaluation_time].each do |attr|
it "should support #{attr}" do
@status.send(attr.to_s + "=", "foo")
@status.send(attr).should == "foo"
@@ -38,7 +43,7 @@ describe Puppet::Resource::Status do
Puppet::Resource::Status.new(@resource).source_description.should == "/my/path"
end
- [:file, :line, :version].each do |attr|
+ [:file, :line].each do |attr|
it "should copy the resource's #{attr}" do
@resource.expects(attr).returns "foo"
Puppet::Resource::Status.new(@resource).send(attr).should == "foo"
@@ -74,7 +79,7 @@ describe Puppet::Resource::Status do
@status.send_log :notice, "my message"
end
- [:file, :line, :version].each do |attr|
+ [:file, :line].each do |attr|
it "should pass the #{attr}" do
Puppet::Util::Log.expects(:new).with { |args| args[attr] == "my val" }
@status.send(attr.to_s + "=", "my val")
@@ -100,4 +105,49 @@ describe Puppet::Resource::Status do
(@status << event).should equal(@status)
@status.events.should == [event]
end
+
+ 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
+ @status.out_of_sync.should == true
+ end
+
+ it "should not start with any changes" do
+ @status.change_count.should == 0
+
+ @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 == 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 == 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
+
+ describe "When converting to YAML" do
+ it "should include only documented attributes" do
+ @status.file = "/foo.rb"
+ @status.line = 27
+ @status.evaluation_time = 2.7
+ @status.tags = %w{one two}
+ @status.to_yaml_properties.should == Puppet::Resource::Status::YAML_ATTRIBUTES.sort
+ end
+ end
end