summaryrefslogtreecommitdiff
path: root/spec/unit/application
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/application')
-rwxr-xr-xspec/unit/application/agent_spec.rb65
-rwxr-xr-xspec/unit/application/apply_spec.rb13
-rwxr-xr-xspec/unit/application/cert_spec.rb2
3 files changed, 77 insertions, 3 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)
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index b12c4fae9..07a39223c 100755
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -20,7 +20,7 @@ describe Puppet::Application::Apply do
Puppet::Node.indirection.cache_class = nil
end
- [:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes].each do |option|
+ [:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes,:catalog].each do |option|
it "should declare handle_#{option} method" do
@apply.should respond_to("handle_#{option}".to_sym)
end
@@ -53,6 +53,17 @@ describe Puppet::Application::Apply do
@apply.handle_logdest("console")
end
+
+ it "should deprecate --apply" do
+ Puppet.expects(:warning).with do |arg|
+ arg.match(/--apply is deprecated/)
+ end
+
+ command_line = Puppet::Util::CommandLine.new('puppet', ['apply', '--apply', 'catalog.json'])
+ apply = Puppet::Application::Apply.new(command_line)
+ apply.stubs(:run_command)
+ apply.run
+ end
end
describe "during setup" do
diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb
index 300234c2b..8f0021ae6 100755
--- a/spec/unit/application/cert_spec.rb
+++ b/spec/unit/application/cert_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
require 'puppet/application/cert'
-describe Puppet::Application::Cert, :'fails_on_ruby_1.9.2' => true do
+describe Puppet::Application::Cert => true do
before :each do
@cert_app = Puppet::Application[:cert]
Puppet::Util::Log.stubs(:newdestination)