diff options
author | Thom May <thom@may.lt> | 2015-08-13 14:52:24 +0100 |
---|---|---|
committer | Thom May <thom@may.lt> | 2015-08-13 14:52:24 +0100 |
commit | 1d06fe16fca529c6f8ea55cba983004f0e9f196f (patch) | |
tree | d3515dc0eee0fba961e024ec500285b163ec8a67 | |
parent | bf1dc8f226954812b0f1b0a1e7a04b7619a70b4a (diff) | |
parent | 82a7f3810cd25ab16a1fb76c808fdfd9131bfe9d (diff) | |
download | chef-1d06fe16fca529c6f8ea55cba983004f0e9f196f.tar.gz |
Merge pull request #3657 from stefanor/upstart-status_command
shell_out! returns an object not an integer
-rw-r--r-- | lib/chef/provider/service/upstart.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/service/upstart_service_spec.rb | 18 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb index 8809d1c708..13145bd055 100644 --- a/lib/chef/provider/service/upstart.rb +++ b/lib/chef/provider/service/upstart.rb @@ -108,7 +108,7 @@ class Chef Chef::Log.debug("#{@new_resource} you have specified a status command, running..") begin - if shell_out!(@new_resource.status_command) == 0 + if shell_out!(@new_resource.status_command).exitstatus == 0 @current_resource.running true end rescue diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index ca7ce8f930..1c8e304cb7 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -19,6 +19,10 @@ require 'spec_helper' describe Chef::Provider::Service::Upstart do + let(:shell_out_success) do + double('shell_out_with_systems_locale', :exitstatus => 0, :error? => false) + end + before(:each) do @node =Chef::Node.new @node.name('upstarter') @@ -173,7 +177,7 @@ describe Chef::Provider::Service::Upstart do end it "should run the services status command if one has been specified" do - allow(@provider).to receive(:shell_out!).with("/bin/chefhasmonkeypants status").and_return(0) + allow(@provider).to receive(:shell_out!).with("/bin/chefhasmonkeypants status").and_return(shell_out_success) expect(@current_resource).to receive(:running).with(true) @provider.load_current_resource end @@ -246,7 +250,7 @@ describe Chef::Provider::Service::Upstart do end it "should call '/sbin/start service_name' if no start command is specified" do - expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0) + expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success) @provider.start_service() end @@ -261,7 +265,7 @@ describe Chef::Provider::Service::Upstart do @new_resource.parameters({ "OSD_ID" => "2" }) @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) @provider.current_resource = @current_resource - expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(0) + expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(shell_out_success) @provider.start_service() end @@ -274,13 +278,13 @@ describe Chef::Provider::Service::Upstart do it "should call '/sbin/restart service_name' if no restart command is specified" do allow(@current_resource).to receive(:running).and_return(true) - expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/restart #{@new_resource.service_name}").and_return(0) + expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/restart #{@new_resource.service_name}").and_return(shell_out_success) @provider.restart_service() end it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do allow(@current_resource).to receive(:running).and_return(false) - expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0) + expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success) @provider.restart_service() end @@ -293,7 +297,7 @@ describe Chef::Provider::Service::Upstart do it "should call '/sbin/reload service_name' if no reload command is specified" do allow(@current_resource).to receive(:running).and_return(true) - expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(0) + expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(shell_out_success) @provider.reload_service() end @@ -306,7 +310,7 @@ describe Chef::Provider::Service::Upstart do it "should call '/sbin/stop service_name' if no stop command is specified" do allow(@current_resource).to receive(:running).and_return(true) - expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(0) + expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(shell_out_success) @provider.stop_service() end |