X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=spec%2Funit%2Frunnerstats_spec.rb;fp=spec%2Funit%2Frunnerstats_spec.rb;h=1002d12439bbbe3304083a8e06c7a00e621b2e66;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/spec/unit/runnerstats_spec.rb b/spec/unit/runnerstats_spec.rb new file mode 100755 index 0000000..1002d12 --- /dev/null +++ b/spec/unit/runnerstats_spec.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env rspec + +require 'spec_helper' + +module MCollective + describe RunnerStats do + before do + Agents.stubs(:agentlist).returns("agents") + Time.stubs(:now).returns(Time.at(0)) + + @stats = RunnerStats.new + + logger = mock + logger.stubs(:log) + logger.stubs(:start) + Log.configure(logger) + end + + describe "#to_hash" do + it "should return the correct data" do + @stats.to_hash.keys.sort.should == [:stats, :threads, :pid, :times, :agents].sort + + @stats.to_hash[:stats].should == {:validated => 0, :unvalidated => 0, :passed => 0, :filtered => 0, + :starttime => 0, :total => 0, :ttlexpired => 0, :replies => 0} + + @stats.to_hash[:agents].should == "agents" + end + end + + [[:ttlexpired, :ttlexpired], [:passed, :passed], [:filtered, :filtered], + [:validated, :validated], [:received, :total], [:sent, :replies]].each do |tst| + describe "##{tst.first}" do + it "should increment #{tst.first}" do + @stats.send(tst.first) + @stats.to_hash[:stats][tst.last].should == 1 + end + end + end + end +end