summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2017-03-21 08:30:43 +0000
committerGitHub <noreply@github.com>2017-03-21 08:30:43 +0000
commit9ecff295ce191c3648a19402ac5412c77689cb59 (patch)
tree51cd14f8cb31656537ecf9de79dcba7216e3f386 /spec
parentc9aceb575404fbdde99ec3bec969e1ee97bca68b (diff)
parent8b7485575ac607bbf518f08832f4746d2a33af30 (diff)
downloadchef-9ecff295ce191c3648a19402ac5412c77689cb59.tar.gz
Merge pull request #5551 from MarkGibbons/smf_recursive_dependencies
smf_recursive_dependencies: Allow solaris services to start recursively.
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb38
-rw-r--r--spec/unit/resource/service_spec.rb22
2 files changed, 58 insertions, 2 deletions
diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index c6835bed64..584176b944 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -198,6 +198,33 @@ describe Chef::Provider::Service::Solaris do
end
end
+ describe "when enabling the service recursively" do
+ before(:each) do
+ @provider.current_resource = @current_resource
+ end
+
+ it "should call svcadm enable -s -r chef" do
+ @new_resource.options("-r")
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
+ expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success)
+ @provider.load_current_resource
+ expect(@provider.enable_service).to be_truthy
+ expect(@current_resource.enabled).to be_truthy
+ end
+
+ it "should call svcadm enable -s -r -t chef when passed an array of options" do
+ @new_resource.options(["-r", "-t"])
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
+ expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success)
+ @provider.load_current_resource
+ expect(@provider.enable_service).to be_truthy
+ expect(@current_resource.enabled).to be_truthy
+ end
+
+ end
+
describe "when disabling the service" do
before(:each) do
@provider.current_resource = @current_resource
@@ -215,7 +242,16 @@ describe Chef::Provider::Service::Solaris do
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
- expect(@provider.stop_service).to be_truthy
+ expect(@provider.disable_service).to be_truthy
+ expect(@current_resource.enabled).to be_falsey
+ end
+
+ it "should call svcadm disable chef with options" do
+ @new_resource.options("-t")
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "-t", "chef").and_return(@success)
+ @provider.load_current_resource
+ expect(@provider.disable_service).to be_truthy
expect(@current_resource.enabled).to be_falsey
end
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index 205282b99f..67a4635983 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -124,6 +124,27 @@ describe Chef::Resource::Service do
end.to raise_error(ArgumentError)
end
+ it "should accept an array for options" do
+ @resource.options ["-r", "-s"]
+ expect(@resource.options).to eql(["-r", "-s"])
+ end
+
+ it "should accept a string for options" do
+ @resource.options "-r"
+ expect(@resource.options).to eql(["-r"])
+ end
+
+ it "should accept a string with multiple flags for options" do
+ @resource.options "-r -s"
+ expect(@resource.options).to eql(["-r", "-s"])
+ end
+
+ it "should not accept a boolean for options" do
+ expect do
+ @resource.options true
+ end.to raise_error(ArgumentError)
+ end
+
%w{enabled running}.each do |attrib|
it "should accept true for #{attrib}" do
@resource.send(attrib, true)
@@ -175,5 +196,4 @@ describe Chef::Resource::Service do
expect(@resource.identity).to eq("superfriend")
end
end
-
end