diff options
| author | Luke Kanies <luke@madstop.com> | 2009-01-19 16:29:17 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2009-02-06 18:08:39 -0600 |
| commit | 8f5cbc349daa868020b009851ee97ea3f29fcfbf (patch) | |
| tree | 5cfc7826cb90d7daf8aa1014b83ee1877255ebee /spec/unit/agent | |
| parent | 25b28c58c22bae718794dc679f10c61665af0b15 (diff) | |
| download | puppet-8f5cbc349daa868020b009851ee97ea3f29fcfbf.tar.gz puppet-8f5cbc349daa868020b009851ee97ea3f29fcfbf.tar.xz puppet-8f5cbc349daa868020b009851ee97ea3f29fcfbf.zip | |
This is work that I've decided not to keep
so I'm just applying it here so it continues to show
up in the history in case I ever want to look at it again.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/agent')
| -rwxr-xr-x | spec/unit/agent/downloader.rb | 19 | ||||
| -rwxr-xr-x | spec/unit/agent/splayer.rb | 42 |
2 files changed, 47 insertions, 14 deletions
diff --git a/spec/unit/agent/downloader.rb b/spec/unit/agent/downloader.rb index 6b07e5bb4..5c53de824 100755 --- a/spec/unit/agent/downloader.rb +++ b/spec/unit/agent/downloader.rb @@ -20,15 +20,6 @@ describe Puppet::Agent::Downloader do dler.source.should == "source" end - it "should be able to provide a timeout value" do - Puppet::Agent::Downloader.should respond_to(:timeout) - end - - it "should use the configtimeout, converted to an integer, as its timeout" do - Puppet.settings.expects(:value).with(:configtimeout).returns "50" - Puppet::Agent::Downloader.timeout.should == 50 - end - describe "when creating the file that does the downloading" do before do @dler = Puppet::Agent::Downloader.new("foo", "path", "source") @@ -118,8 +109,8 @@ describe Puppet::Agent::Downloader do @dler.evaluate end - it "should set a timeout for the download" do - Puppet::Agent::Downloader.expects(:timeout).returns 50 + it "should use the agent timeout for the download" do + Puppet::Agent.expects(:timeout).returns 50 Timeout.expects(:timeout).with(50) @dler.evaluate @@ -153,7 +144,7 @@ describe Puppet::Agent::Downloader do @dler.evaluate.should == %w{/changed/file} end - it "should yield the resources if a block is given" do + it "should yield the downloaded file's path if a block is given" do trans = mock 'transaction' catalog = mock 'catalog' @@ -163,13 +154,13 @@ describe Puppet::Agent::Downloader do Timeout.expects(:timeout).yields resource = mock 'resource' - resource.expects(:[]).with(:path).returns "/changed/file" + resource.stubs(:[]).with(:path).returns "/changed/file" trans.expects(:changed?).returns([resource]) yielded = nil @dler.evaluate { |r| yielded = r } - yielded.should == resource + yielded.should == "/changed/file" end it "should catch and log exceptions" do diff --git a/spec/unit/agent/splayer.rb b/spec/unit/agent/splayer.rb new file mode 100755 index 000000000..e097cc98b --- /dev/null +++ b/spec/unit/agent/splayer.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/agent/splayer' + +describe Puppet::Agent::Splayer do + it "should be able to splay" do + Puppet::Agent::Splayer.new.should respond_to(:splay) + end + + describe "when splaying" do + before do + @agent = Puppet::Agent::Splayer.new + @agent.stubs(:name).returns "foo" + + Puppet.settings.stubs(:value).with(:splaylimit).returns "1800" + Puppet.settings.stubs(:value).with(:splay).returns true + end + + it "should sleep if it has not previously splayed" do + Puppet.settings.expects(:value).with(:splay).returns true + @agent.expects(:sleep) + @agent.splay + end + + it "should do nothing if it has already splayed" do + @agent.expects(:sleep).once + @agent.splay + @agent.splay + end + + it "should log if it is sleeping" do + Puppet.settings.expects(:value).with(:splay).returns true + @agent.stubs(:sleep) + + Puppet.expects(:info) + + @agent.splay + end + end +end |
