diff options
author | Paul Berry <paul@puppetlabs.com> | 2010-12-29 14:09:57 -0800 |
---|---|---|
committer | Paul Berry <paul@puppetlabs.com> | 2010-12-30 11:50:51 -0800 |
commit | a4e40f4dd5990df4dc6b2be065e82a142a31b6fc (patch) | |
tree | 30e7c792f7e1997d34efd79bc1c81f81e70afcfc /spec | |
parent | 15dda94c7d1e117273928f094b46a81b3f842c1f (diff) | |
download | puppet-a4e40f4dd5990df4dc6b2be065e82a142a31b6fc.tar.gz puppet-a4e40f4dd5990df4dc6b2be065e82a142a31b6fc.tar.xz puppet-a4e40f4dd5990df4dc6b2be065e82a142a31b6fc.zip |
(#5715) Refactor in preparation for adding a status attribute to reports.
Renamed Puppet::Transaction::Report#calculate_metrics to
finalize_report, in preparation for adding more functionality to this
method.
Removed Puppet::Transaction#send_report and
Puppet::Transaction#generate_report. The former was never used, and
the latter was unnecessary.
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/configurer_spec.rb | 22 | ||||
-rwxr-xr-x | spec/unit/transaction/report_spec.rb | 20 | ||||
-rwxr-xr-x | spec/unit/transaction_spec.rb | 5 |
3 files changed, 17 insertions, 30 deletions
diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb index 3b2a44f0f..cf73a3706 100755 --- a/spec/unit/configurer_spec.rb +++ b/spec/unit/configurer_spec.rb @@ -233,16 +233,8 @@ describe Puppet::Configurer, "when sending a report" do @trans = stub 'transaction' end - it "should require a report" do - lambda { @configurer.send_report }.should raise_error(ArgumentError) - end - - it "should allow specification of a transaction" do - lambda { @configurer.send_report(@report, @trans) }.should_not raise_error(ArgumentError) - end - - it "should use any provided transaction to add metrics to the report" do - @trans.expects(:generate_report) + it "should finalize the report" do + @report.expects(:finalize_report) @configurer.send_report(@report, @trans) end @@ -252,28 +244,28 @@ describe Puppet::Configurer, "when sending a report" do @report.expects(:summary).returns "stuff" @configurer.expects(:puts).with("stuff") - @configurer.send_report(@report) + @configurer.send_report(@report, nil) end it "should not print a report summary if not configured to do so" do Puppet.settings[:summarize] = false @configurer.expects(:puts).never - @configurer.send_report(@report) + @configurer.send_report(@report, nil) end it "should save the report if reporting is enabled" do Puppet.settings[:report] = true @report.expects(:save) - @configurer.send_report(@report) + @configurer.send_report(@report, nil) end it "should not save the report if reporting is disabled" do Puppet.settings[:report] = false @report.expects(:save).never - @configurer.send_report(@report) + @configurer.send_report(@report, nil) end it "should log but not fail if saving the report fails" do @@ -282,7 +274,7 @@ describe Puppet::Configurer, "when sending a report" do @report.expects(:save).raises "whatever" Puppet.expects(:err) - lambda { @configurer.send_report(@report) }.should_not raise_error + lambda { @configurer.send_report(@report, nil) }.should_not raise_error end end diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb index 8c4ed8afe..98be28755 100755 --- a/spec/unit/transaction/report_spec.rb +++ b/spec/unit/transaction/report_spec.rb @@ -145,7 +145,7 @@ describe Puppet::Transaction::Report do [:time, :resources, :changes, :events].each do |type| it "should add #{type} metrics" do - @report.calculate_metrics + @report.finalize_report @report.metrics[type.to_s].should be_instance_of(Puppet::Transaction::Metric) end end @@ -154,7 +154,7 @@ describe Puppet::Transaction::Report do it "should provide the total number of resources" do add_statuses(3) - @report.calculate_metrics + @report.finalize_report metric(:resources, :total).should == 3 end @@ -162,7 +162,7 @@ describe Puppet::Transaction::Report do it "should provide the number of #{state} resources as determined by the status objects" do add_statuses(3) { |status| status.send(state.to_s + "=", true) } - @report.calculate_metrics + @report.finalize_report metric(:resources, state).should == 3 end end @@ -171,7 +171,7 @@ describe Puppet::Transaction::Report do describe "for changes" do it "should provide the number of changes from the resource statuses" do add_statuses(3) { |status| 3.times { status << Puppet::Transaction::Event.new(:status => 'success') } } - @report.calculate_metrics + @report.finalize_report metric(:changes, :total).should == 9 end end @@ -188,7 +188,7 @@ describe Puppet::Transaction::Report do status.evaluation_time = 3 end - @report.calculate_metrics + @report.finalize_report metric(:time, "file").should == 3 metric(:time, "exec").should == 6 @@ -197,7 +197,7 @@ describe Puppet::Transaction::Report do it "should add any provided times from external sources" do @report.add_times :foobar, 50 - @report.calculate_metrics + @report.finalize_report metric(:time, "foobar").should == 50 end @@ -206,7 +206,7 @@ describe Puppet::Transaction::Report do status.evaluation_time = 1.25 end @report.add_times :config_retrieval, 0.5 - @report.calculate_metrics + @report.finalize_report metric(:time, "total").should == 4.25 end end @@ -216,7 +216,7 @@ describe Puppet::Transaction::Report do add_statuses(3) do |status| 3.times { |i| status.add_event(Puppet::Transaction::Event.new) } end - @report.calculate_metrics + @report.finalize_report metric(:events, :total).should == 9 end @@ -230,7 +230,7 @@ describe Puppet::Transaction::Report do end end - @report.calculate_metrics + @report.finalize_report metric(:events, status_name).should == 9 end end @@ -245,7 +245,7 @@ describe Puppet::Transaction::Report do trans = catalog.apply @report = trans.report - @report.calculate_metrics + @report.finalize_report end %w{Changes Total Resources}.each do |main| diff --git a/spec/unit/transaction_spec.rb b/spec/unit/transaction_spec.rb index 566c90438..862413a31 100755 --- a/spec/unit/transaction_spec.rb +++ b/spec/unit/transaction_spec.rb @@ -58,11 +58,6 @@ describe Puppet::Transaction do @transaction.report.resource_statuses[resource.to_s].should equal(status) end - it "should calculate metrics on and report the report when asked to generate a report" do - @transaction.report.expects(:calculate_metrics) - @transaction.generate_report.should equal(@transaction.report) - end - it "should consider a resource to be failed if a status instance exists for that resource and indicates it is failed" do resource = Puppet::Type.type(:notify).new :name => "yayness" status = Puppet::Resource::Status.new(resource) |