summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2014-06-18 13:35:42 -0700
committersersut <serdar@opscode.com>2014-06-18 13:35:42 -0700
commit26ef3a3a1ef6f1b02578a4636ed89c00e21c3c71 (patch)
treee14b3578da493721d71d8310cbc4e5da8562b8f8 /spec
parent8b94d87ac6e33b08bbfd1ff46e9db3fd2464e337 (diff)
parent5439694dcdfceb12add4a5409477e2e14296c457 (diff)
downloadchef-26ef3a3a1ef6f1b02578a4636ed89c00e21c3c71.tar.gz
Merge branch 'CHEF-4791' of github.com:deployable/chef
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/service/windows_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 08f5a81a9d..a007e7b984 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -92,8 +92,39 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
@provider.start_service
@new_resource.updated_by_last_action?.should be_false
end
+
+ it "should raise an error if the service is paused" do
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
+ double("StatusStruct", :current_state => "paused"))
+ @provider.load_current_resource
+ Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
+ expect { @provider.start_service }.to raise_error( Chef::Exceptions::Service )
+ @new_resource.updated_by_last_action?.should be_false
+ end
+
+ it "should wait and continue if the service is in start_pending" do
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
+ double("StatusStruct", :current_state => "start pending"),
+ double("StatusStruct", :current_state => "start pending"),
+ double("StatusStruct", :current_state => "running"))
+ @provider.load_current_resource
+ Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
+ @provider.start_service
+ @new_resource.updated_by_last_action?.should be_false
+ end
+
+ it "should fail if the service is in stop_pending" do
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
+ double("StatusStruct", :current_state => "stop pending"))
+ @provider.load_current_resource
+ Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
+ expect { @provider.start_service }.to raise_error( Chef::Exceptions::Service )
+ @new_resource.updated_by_last_action?.should be_false
+ end
+
end
+
describe Chef::Provider::Service::Windows, "stop_service" do
before(:each) do
@@ -130,6 +161,36 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
@provider.stop_service
@new_resource.updated_by_last_action?.should be_false
end
+
+ it "should raise an error if the service is paused" do
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
+ double("StatusStruct", :current_state => "paused"))
+ @provider.load_current_resource
+ Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
+ expect { @provider.stop_service }.to raise_error( Chef::Exceptions::Service )
+ @new_resource.updated_by_last_action?.should be_false
+ end
+
+ it "should wait and continue if the service is in stop_pending" do
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
+ double("StatusStruct", :current_state => "stop pending"),
+ double("StatusStruct", :current_state => "stop pending"),
+ double("StatusStruct", :current_state => "stopped"))
+ @provider.load_current_resource
+ Win32::Service.should_not_receive(:stop).with(@new_resource.service_name)
+ @provider.stop_service
+ @new_resource.updated_by_last_action?.should be_false
+ end
+
+ it "should fail if the service is in start_pending" do
+ Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
+ double("StatusStruct", :current_state => "start pending"))
+ @provider.load_current_resource
+ Win32::Service.should_not_receive(:stop).with(@new_resource.service_name)
+ expect { @provider.stop_service }.to raise_error( Chef::Exceptions::Service )
+ @new_resource.updated_by_last_action?.should be_false
+ end
+
end
describe Chef::Provider::Service::Windows, "restart_service" do