diff options
Diffstat (limited to 'spec/unit/application/agent_spec.rb')
-rwxr-xr-x | spec/unit/application/agent_spec.rb | 65 |
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) |