summaryrefslogtreecommitdiff
path: root/spec/unit/application/agent_spec.rb
diff options
context:
space:
mode:
authorStig Sandbeck Mathisen <ssm@debian.org>2012-01-26 11:22:40 +0100
committerStig Sandbeck Mathisen <ssm@debian.org>2012-01-26 11:22:40 +0100
commitc17b3ba16e7013f06416f10b8752ef783f048717 (patch)
tree790f13f167199b954007e17d1c55a8d1b0218775 /spec/unit/application/agent_spec.rb
parent32af6143486ceb24a93636445d1883f5fe2299d7 (diff)
downloadpuppet-upstream/2.7.10.tar.gz
Imported Upstream version 2.7.10upstream/2.7.10
Diffstat (limited to 'spec/unit/application/agent_spec.rb')
-rwxr-xr-xspec/unit/application/agent_spec.rb65
1 files changed, 64 insertions, 1 deletions
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index 6d31ec34a..13be1a5af 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -91,7 +91,7 @@ describe Puppet::Application::Agent do
@puppetd.command_line.stubs(:args).returns([])
end
- [:centrallogging, :disable, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
+ [:centrallogging, :enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
it "should declare handle_#{option} method" do
@puppetd.should respond_to("handle_#{option}".to_sym)
end
@@ -102,6 +102,24 @@ describe Puppet::Application::Agent do
end
end
+ describe "when handling --disable" do
+ it "should declare handle_disable method" do
+ @puppetd.should respond_to(:handle_disable)
+ end
+
+ it "should set disable to true" do
+ @puppetd.options.stubs(:[]=)
+ @puppetd.options.expects(:[]=).with(:disable, true)
+ @puppetd.handle_disable('')
+ end
+
+ it "should store disable message" do
+ @puppetd.options.stubs(:[]=)
+ @puppetd.options.expects(:[]=).with(:disable_message, "message")
+ @puppetd.handle_disable('message')
+ end
+ end
+
it "should set an existing handler on server" do
Puppet::Network::Handler.stubs(:handler).with("handler").returns(true)
@@ -349,6 +367,20 @@ describe Puppet::Application::Agent do
end
end
+ it "should pass the disable message when disabling" do
+ @puppetd.options.stubs(:[]).with(:disable).returns(true)
+ @puppetd.options.stubs(:[]).with(:disable_message).returns("message")
+ @agent.expects(:disable).with("message")
+ expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
+ end
+
+ it "should pass the default disable message when disabling without a message" do
+ @puppetd.options.stubs(:[]).with(:disable).returns(true)
+ @puppetd.options.stubs(:[]).with(:disable_message).returns(nil)
+ @agent.expects(:disable).with("reason not specified")
+ expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
+ end
+
it "should finally exit" do
expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
end
@@ -437,6 +469,32 @@ describe Puppet::Application::Agent do
@puppetd.setup_listen
end
end
+
+ describe "when setting up for fingerprint" do
+ before(:each) do
+ @puppetd.options.stubs(:[]).with(:fingerprint).returns(true)
+ end
+
+ it "should not setup as an agent" do
+ @puppetd.expects(:setup_agent).never
+ @puppetd.setup
+ end
+
+ it "should not create an agent" do
+ Puppet::Agent.stubs(:new).with(Puppet::Configurer).never
+ @puppetd.setup
+ end
+
+ it "should not daemonize" do
+ @daemon.expects(:daemonize).never
+ @puppetd.setup
+ end
+
+ it "should setup our certificate host" do
+ @puppetd.expects(:setup_host)
+ @puppetd.setup
+ end
+ end
end
@@ -497,6 +555,11 @@ describe Puppet::Application::Agent do
expect { @puppetd.onetime }.to exit_with 0
end
+ it "should stop the daemon" do
+ @daemon.expects(:stop).with(:exit => false)
+ expect { @puppetd.onetime }.to exit_with 0
+ end
+
describe "and --detailed-exitcodes" do
before :each do
@puppetd.options.stubs(:[]).with(:detailed_exitcodes).returns(true)