summaryrefslogtreecommitdiff
path: root/spec/unit/provider/service/upstart_service_spec.rb
diff options
context:
space:
mode:
authorAbhishekKr <abhikumar163@gmail.com>2016-09-10 02:28:30 +0530
committerAbhishekKr <abhikumar163@gmail.com>2016-09-10 02:28:30 +0530
commit5c01c0f74941d4f788e254ae4d040c0e4a2a477d (patch)
tree8cf25328d577db77d191d88bdc85277629553f3e /spec/unit/provider/service/upstart_service_spec.rb
parentc3c6cfc156d0a0bfe7c7dd4f273a2c2bdc4b0281 (diff)
parent3731bff0641d0cb12780bc52376e50d9a0a71644 (diff)
downloadchef-5c01c0f74941d4f788e254ae4d040c0e4a2a477d.tar.gz
Merge branch 'master' of https://github.com/chef/chef
Diffstat (limited to 'spec/unit/provider/service/upstart_service_spec.rb')
-rw-r--r--spec/unit/provider/service/upstart_service_spec.rb39
1 files changed, 27 insertions, 12 deletions
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb
index 0692bdb64a..f768a46ccf 100644
--- a/spec/unit/provider/service/upstart_service_spec.rb
+++ b/spec/unit/provider/service/upstart_service_spec.rb
@@ -105,17 +105,21 @@ describe Chef::Provider::Service::Upstart do
end
describe "when the status command uses the new format" do
- before do
+ it "should set running to true if the goal state is 'start'" do
+ @stdout = StringIO.new("rsyslog start/running")
+ allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.load_current_resource
+ expect(@current_resource.running).to be_truthy
end
- it "should set running to true if the status command returns 0" do
- @stdout = StringIO.new("rsyslog start/running")
+ it "should set running to true if the goal state is 'start' but current state is not 'running'" do
+ @stdout = StringIO.new("rsyslog start/starting")
allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_truthy
end
- it "should set running to false if the status command returns anything except 0" do
+ it "should set running to false if the goal state is 'stop'" do
@stdout = StringIO.new("rsyslog stop/waiting")
allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@@ -124,17 +128,21 @@ describe Chef::Provider::Service::Upstart do
end
describe "when the status command uses the new format with an instance" do
- before do
+ it "should set running to true if the goal state is 'start'" do
+ @stdout = StringIO.new("rsyslog (test) start/running, process 100")
+ allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.load_current_resource
+ expect(@current_resource.running).to be_truthy
end
- it "should set running to true if the status command returns 0" do
- @stdout = StringIO.new("rsyslog (test) start/running, process 100")
+ it "should set running to true if the goal state is 'start' but current state is not 'running'" do
+ @stdout = StringIO.new("rsyslog (test) start/starting, process 100")
allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_truthy
end
- it "should set running to false if the status command returns anything except 0" do
+ it "should set running to false if the goal state is 'stop'" do
@stdout = StringIO.new("rsyslog (test) stop/waiting, process 100")
allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@@ -143,14 +151,21 @@ describe Chef::Provider::Service::Upstart do
end
describe "when the status command uses the old format" do
- it "should set running to true if the status command returns 0" do
+ it "should set running to true if the goal state is 'start'" do
@stdout = StringIO.new("rsyslog (start) running, process 32225")
allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
expect(@current_resource.running).to be_truthy
end
- it "should set running to false if the status command returns anything except 0" do
+ it "should set running to true if the goal state is 'start' but current state is not 'running'" do
+ @stdout = StringIO.new("rsyslog (start) starting, process 32225")
+ allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
+ @provider.load_current_resource
+ expect(@current_resource.running).to be_truthy
+ end
+
+ it "should set running to false if the goal state is 'stop'" do
@stdout = StringIO.new("rsyslog (stop) waiting")
allow(@provider).to receive(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
@provider.load_current_resource
@@ -214,8 +229,8 @@ describe Chef::Provider::Service::Upstart do
end
end
- it "should track state when we fail to obtain service status via upstart_state" do
- expect(@provider).to receive(:upstart_state).and_raise Chef::Exceptions::Exec
+ it "should track state when we fail to obtain service status via upstart_goal_state" do
+ expect(@provider).to receive(:upstart_goal_state).and_raise Chef::Exceptions::Exec
@provider.load_current_resource
expect(@provider.instance_variable_get("@command_success")).to eq(false)
end