|
40 | 40 | lambda { @provider.assert_update_rcd_available }.should raise_error(Chef::Exceptions::Service) |
41 | 41 | end |
42 | 42 |
|
| 43 | + describe "when update-rc.d shows the init script linked to rc*.d/" do |
| 44 | + before do |
| 45 | + @provider.stub!(:run_command) |
| 46 | + @provider.stub!(:assert_update_rcd_available) |
| 47 | + @status = mock("Status", :exitstatus => 0) |
| 48 | + |
| 49 | + result=<<-UPDATE_RC_D_SUCCESS |
| 50 | +Removing any system startup links for /etc/init.d/chef ... |
| 51 | + /etc/rc0.d/K20chef |
| 52 | + /etc/rc1.d/K20chef |
| 53 | + /etc/rc2.d/S20chef |
| 54 | + /etc/rc3.d/S20chef |
| 55 | + /etc/rc4.d/S20chef |
| 56 | + /etc/rc5.d/S20chef |
| 57 | + /etc/rc6.d/K20chef |
| 58 | + UPDATE_RC_D_SUCCESS |
| 59 | + @stdout = StringIO.new(result) |
| 60 | + @stderr = StringIO.new |
| 61 | + @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
| 62 | + end |
| 63 | + |
| 64 | + it "says the service is enabled" do |
| 65 | + @provider.service_currently_enabled?.should be_true |
| 66 | + end |
| 67 | + |
| 68 | + it "stores the 'enabled' state" do |
| 69 | + Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
| 70 | + @provider.load_current_resource.should equal(@current_resource) |
| 71 | + @current_resource.enabled.should be_true |
| 72 | + end |
| 73 | + end |
43 | 74 |
|
44 | 75 | {"Debian/Lenny and older" => { |
45 | 76 | "linked" => { |
|
132 | 163 | end |
133 | 164 | end |
134 | 165 |
|
| 166 | + describe "when update-rc.d shows the init script isn't linked to rc*.d" do |
| 167 | + before do |
| 168 | + @provider.stub!(:run_command) |
| 169 | + @provider.stub!(:assert_update_rcd_available) |
| 170 | + @status = mock("Status", :exitstatus => 0) |
| 171 | + @stdout = StringIO.new(" Removing any system startup links for /etc/init.d/chef ...") |
| 172 | + @stderr = StringIO.new |
| 173 | + @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
| 174 | + end |
| 175 | + |
| 176 | + it "says the service is disabled" do |
| 177 | + @provider.service_currently_enabled?.should be_false |
| 178 | + end |
| 179 | + |
| 180 | + it "stores the 'disabled' state" do |
| 181 | + Chef::Resource::Service.stub!(:new).and_return(@current_resource) |
| 182 | + @provider.load_current_resource.should equal(@current_resource) |
| 183 | + @current_resource.enabled.should be_false |
| 184 | + end |
| 185 | + end |
| 186 | + |
135 | 187 | describe "when update-rc.d fails" do |
136 | 188 | before do |
137 | 189 | @status = mock("Status", :exitstatus => -1) |
|
173 | 225 | end |
174 | 226 |
|
175 | 227 | describe "when disabling a service" do |
176 | | - it "should call update-rc.d 'service_name' disable" do |
177 | | - @provider.should_receive(:run_command).with({:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} disable"}) |
| 228 | + it "should call update-rc.d -f 'service_name' remove" do |
| 229 | + @provider.should_receive(:run_command).with({:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove"}) |
178 | 230 | @provider.disable_service() |
179 | 231 | end |
180 | 232 | end |
|
0 commit comments