diff options
author | Robby Dyer <rdyer@tropo.com> | 2014-06-17 14:53:46 -0400 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-08-18 13:40:45 -0700 |
commit | b5e9c70e43b8d37eee1fb9f5aaae391125c4cc22 (patch) | |
tree | 3d60b52c13c5ce007c00ba9cf3409beca15af1d7 /spec/unit/provider/service/redhat_spec.rb | |
parent | 1bdf739b844489424283852af56f5a8f2b8f362a (diff) | |
download | chef-b5e9c70e43b8d37eee1fb9f5aaae391125c4cc22.tar.gz |
CHEF-5372: Support specific run_levels for RedHat service
Diffstat (limited to 'spec/unit/provider/service/redhat_spec.rb')
-rw-r--r-- | spec/unit/provider/service/redhat_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 73cfec8a6f..78be98f533 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -83,6 +83,28 @@ describe "Chef::Provider::Service::Redhat" do expect(@provider.load_current_resource).to eql(@current_resource) expect(@current_resource.enabled).to be_falsey end + + it "sets the current enabled status to true if the service is enabled at specified run levels" do + status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + @current_resource.instance_variable_set(:@run_levels, [ 1, 2 ]) + @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) + chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "") + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) + @provider.instance_variable_get("@service_missing").should be_false + @provider.load_current_resource.should + @current_resource.enabled.should be_true + end + + it "sets the current enabled status to false if the service is not enabled at specified run levels" do + status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + @current_resource.instance_variable_set(:@run_levels, [ 2 ]) + @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) + chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "") + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) + @provider.instance_variable_get("@service_missing").should be_false + @provider.load_current_resource.should + @current_resource.enabled.should be_true + end end describe "define resource requirements" do @@ -144,6 +166,12 @@ describe "Chef::Provider::Service::Redhat" do expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig #{@new_resource.service_name} on") @provider.enable_service end + + it "should call chkconfig to add 'service_name' at specified run_levels" do + @provider.instance_variable_set(:@run_levels, [ 1,2 ]) + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} on") + @provider.enable_service + end end describe "disable_service" do @@ -151,6 +179,12 @@ describe "Chef::Provider::Service::Redhat" do expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig #{@new_resource.service_name} off") @provider.disable_service end + + it "should call chkconfig to del 'service_name' at specified run_levels" do + @provider.instance_variable_set(:@run_levels, [ 1,2 ]) + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} off") + @provider.disable_service + end end end |