summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <mcquin@users.noreply.github.com>2014-06-17 13:02:05 -0700
committerClaire McQuin <mcquin@users.noreply.github.com>2014-06-17 13:02:05 -0700
commit878d5453a48072a60e39257bda7145ffcb7ae520 (patch)
tree39ec6cc4bea6bd2e1b6aa369c75aace8af784f42
parent7dea8cde7707843c6f2d1e5445fded9b35c7bdc8 (diff)
parent69ccdffdac8fa61cc708b952688049c675026cac (diff)
downloadchef-878d5453a48072a60e39257bda7145ffcb7ae520.tar.gz
Merge pull request #1477 from MarkGibbons/CHEF-5347
CHEF-5347: Allow for undefined solaris services in the service resource.
-rw-r--r--lib/chef/provider/service/solaris.rb2
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb25
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb
index 05a91eb756..69a79e6226 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -69,7 +69,7 @@ class Chef
end
def service_status
- status = shell_out!("#{@status_command} #{@current_resource.service_name}")
+ status = shell_out!("#{@status_command} #{@current_resource.service_name}", :returns => [0, 1])
status.stdout.each_line do |line|
case line
when /state\s+online/
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index 8e66289a80..978f149258 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -66,7 +66,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call '/bin/svcs -l service_name'" do
- @provider.should_receive(:shell_out!).with("/bin/svcs -l chef").and_return(@status)
+ @provider.should_receive(:shell_out!).with("/bin/svcs -l chef", {:returns=>[0, 1]}).and_return(@status)
@provider.load_current_resource
end
@@ -145,7 +145,7 @@ describe Chef::Provider::Service::Solaris do
end
it "should call svcadm disable -s chef for stop_service" do
- @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm disable -s chef")
+ @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm disable -s chef").and_return(@status)
@provider.stop_service.should be_true
@current_resource.enabled.should be_false
end
@@ -164,5 +164,26 @@ describe Chef::Provider::Service::Solaris do
end
end
+
+ describe "when the service doesn't exist" do
+ before(:each) do
+ @stdout_string = ""
+ @status = double("Status", :exitstatus => 1, :stdout => @stdout)
+ @provider.current_resource = @current_resource
+ end
+
+ it "should be marked not running" do
+ @provider.should_receive(:shell_out!).with("/bin/svcs -l chef", {:returns=>[0, 1]}).and_return(@status)
+ @provider.service_status
+ @current_resource.running.should be_false
+ end
+
+ it "should be marked not enabled" do
+ @provider.should_receive(:shell_out!).with("/bin/svcs -l chef", {:returns=>[0, 1]}).and_return(@status)
+ @provider.service_status
+ @current_resource.enabled.should be_false
+ end
+
+ end
end
end