summaryrefslogtreecommitdiff
path: root/spec/unit/provider/service
diff options
context:
space:
mode:
authorkaustubh-d <kaustubh@clogeny.com>2014-09-15 23:00:58 +0530
committerkaustubh-d <kaustubh@clogeny.com>2014-09-15 23:00:58 +0530
commite01488c625ba11ec0ff4f9a9eeb81bcc0f829c3e (patch)
treec2bb73323598ef16b192f4cf30dab2c5a7e985e2 /spec/unit/provider/service
parentf2c6433811852b98f6f772c37daaab26702a8f5b (diff)
downloadchef-e01488c625ba11ec0ff4f9a9eeb81bcc0f829c3e.tar.gz
aix service provider more code changes
Diffstat (limited to 'spec/unit/provider/service')
-rw-r--r--spec/unit/provider/service/aix_service_spec.rb68
1 files changed, 67 insertions, 1 deletions
diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb
index 451eecfa2c..070f618b99 100644
--- a/spec/unit/provider/service/aix_service_spec.rb
+++ b/spec/unit/provider/service/aix_service_spec.rb
@@ -39,11 +39,77 @@ describe Chef::Provider::Service::Aix do
Chef::Resource::Service.should_receive(:new).and_return(@current_resource)
@current_resource.should_receive(:service_name).with("chef")
@provider.should_receive(:determine_current_status!)
- @provider.should_receive(:is_resource_group?)
@provider.load_current_resource
end
+ end
+
+ describe "determine current status" do
+ context "when the service is active" do
+ before do
+ @status = double("Status", :exitstatus => 0, :stdout => "chef chef 12345 active\n")
+ end
+
+ it "current resource is running" do
+ @provider.should_receive(:shell_out!).with("lssrc -a | grep -w chef").and_return(@status)
+ @provider.should_receive(:is_resource_group?).with(["chef chef 12345 active"])
+
+ @provider.load_current_resource
+ @current_resource.running.should be_true
+ end
+ end
+ context "when the service is inoprative" do
+ before do
+ @status = double("Status", :exitstatus => 0, :stdout => "chef chef inoperative\n")
+ end
+
+ it "current resource is not running" do
+ @provider.should_receive(:shell_out!).with("lssrc -a | grep -w chef").and_return(@status)
+ @provider.should_receive(:is_resource_group?).with(["chef chef inoperative"])
+
+ @provider.load_current_resource
+ @current_resource.running.should be_false
+ end
+ end
+ end
+
+ describe "is resource group" do
+ context "when there are mutiple subsystems associated with group" do
+ before do
+ @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef 12345 active\nchef2 chef 12334 active\nchef3 chef inoperative")
+ end
+
+ it "service is a group" do
+ @provider.should_receive(:shell_out!).with("lssrc -a | grep -w chef").and_return(@status)
+ @provider.load_current_resource
+ @provider.instance_eval("@is_resource_group").should be_true
+ end
+ end
+
+ context "when there is a single subsystem in the group" do
+ before do
+ @status = double("Status", :exitstatus => 0, :stdout => "chef1 chef inoperative\n")
+ end
+
+ it "service is a group" do
+ @provider.should_receive(:shell_out!).with("lssrc -a | grep -w chef").and_return(@status)
+ @provider.load_current_resource
+ @provider.instance_eval("@is_resource_group").should be_true
+ end
+ end
+
+ context "when there service is a subsytem" do
+ before do
+ @status = double("Status", :exitstatus => 0, :stdout => "chef chef123 inoperative\n")
+ end
+
+ it "service is a subsystem" do
+ @provider.should_receive(:shell_out!).with("lssrc -a | grep -w chef").and_return(@status)
+ @provider.load_current_resource
+ @provider.instance_eval("@is_resource_group").should be_false
+ end
+ end
end
describe "when starting the service" do