diff options
-rw-r--r-- | lib/puppet/transaction/report.rb | 9 | ||||
-rwxr-xr-x | spec/unit/transaction/report.rb | 72 |
2 files changed, 46 insertions, 35 deletions
diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index 6a486335b..0fb1db03c 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -26,11 +26,6 @@ class Puppet::Transaction::Report def initialize @metrics = {} @logs = [] - - @records = Hash.new do |hash, key| - hash[key] = [] - end - @host = Puppet[:certname] end @@ -54,10 +49,6 @@ class Puppet::Transaction::Report @logs << msg end - def record(metric, object) - @records[metric] << object - end - # Provide a summary of this report. def summary ret = "" diff --git a/spec/unit/transaction/report.rb b/spec/unit/transaction/report.rb index 7cd5e1451..e576f2393 100755 --- a/spec/unit/transaction/report.rb +++ b/spec/unit/transaction/report.rb @@ -1,41 +1,61 @@ #!/usr/bin/env ruby -# -# Created by Luke Kanies on 2007-10-12. -# Copyright (c) 2007. All rights reserved. require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/transaction/report' -describe Puppet::Transaction::Report, " when being indirect" do - it "should redirect :find to the indirection" do - @indirection = stub 'indirection', :name => :report - Puppet::Transaction::Report.stubs(:indirection).returns(@indirection) - @indirection.expects(:find) - Puppet::Transaction::Report.find(:report) +describe Puppet::Transaction::Report do + it "should set its host name to the certname" do + Puppet.settings.expects(:value).with(:certname).returns "myhost" + Puppet::Transaction::Report.new.host.should == "myhost" end - it "should redirect :save to the indirection" do - Facter.stubs(:value).returns("eh") - @indirection = stub 'indirection', :name => :report - Puppet::Transaction::Report.stubs(:indirection).returns(@indirection) - report = Puppet::Transaction::Report.new - @indirection.expects(:save) - report.save - end + describe "when accepting logs" do + before do + @report = Puppet::Transaction::Report.new + end - it "should default to the 'processor' terminus" do - Puppet::Transaction::Report.indirection.terminus_class.should == :processor - end + it "should add new logs to the log list" do + @report << "log" + @report.logs[-1].should == "log" + end - it "should delegate its name attribute to its host method" do - report = Puppet::Transaction::Report.new - report.expects(:host).returns "me" - report.name.should == "me" + it "should return self" do + r = @report << "log" + r.should equal(@report) + end end - after do - Puppet::Util::Cacher.expire + describe "when using the indirector" do + it "should redirect :find to the indirection" do + @indirection = stub 'indirection', :name => :report + Puppet::Transaction::Report.stubs(:indirection).returns(@indirection) + @indirection.expects(:find) + Puppet::Transaction::Report.find(:report) + end + + it "should redirect :save to the indirection" do + Facter.stubs(:value).returns("eh") + @indirection = stub 'indirection', :name => :report + Puppet::Transaction::Report.stubs(:indirection).returns(@indirection) + report = Puppet::Transaction::Report.new + @indirection.expects(:save) + report.save + end + + it "should default to the 'processor' terminus" do + Puppet::Transaction::Report.indirection.terminus_class.should == :processor + end + + it "should delegate its name attribute to its host method" do + report = Puppet::Transaction::Report.new + report.expects(:host).returns "me" + report.name.should == "me" + end + + after do + Puppet::Util::Cacher.expire + end end end |