diff options
| author | Luke Kanies <luke@madstop.com> | 2009-06-16 13:11:26 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-06-26 11:38:02 +1000 |
| commit | 5680cd5029c8b3a2cf5a2a3b10df6acf7a9fc870 (patch) | |
| tree | 4b760295be6d48cdc4f5febfcbfe99454e761f72 /spec/unit | |
| parent | 603b9cf1a435f6662db39be66f91527a8e20c112 (diff) | |
| download | puppet-5680cd5029c8b3a2cf5a2a3b10df6acf7a9fc870.tar.gz puppet-5680cd5029c8b3a2cf5a2a3b10df6acf7a9fc870.tar.xz puppet-5680cd5029c8b3a2cf5a2a3b10df6acf7a9fc870.zip | |
Fixing #2197 - daemontools tests now pass
This actually involved a bit of rewriting
of the code, but the code's simpler now, too.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
| -rw-r--r-- | spec/unit/provider/service/daemontools.rb | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/spec/unit/provider/service/daemontools.rb b/spec/unit/provider/service/daemontools.rb index 2e9abaca8..4156afb1f 100644 --- a/spec/unit/provider/service/daemontools.rb +++ b/spec/unit/provider/service/daemontools.rb @@ -30,11 +30,17 @@ describe provider_class do @resource.stubs(:[]).with(:path).returns @daemondir @resource.stubs(:ref).returns "Service[myservice]" - @provider.stubs(:resource).returns @resource + @provider.resource = @resource + + @provider.stubs(:command).with(:svc).returns "svc" + @provider.stubs(:command).with(:svstat).returns "svstat" + + @provider.stubs(:svc) + @provider.stubs(:svstat) end - it "should have a restartcmd method" do - @provider.should respond_to(:restartcmd) + it "should have a restart method" do + @provider.should respond_to(:restart) end it "should have a start method" do @@ -58,19 +64,40 @@ describe provider_class do end describe "when starting" do - it "should call enable" do + it "should use 'svc' to start the service" do + @provider.stubs(:enabled?).returns true + @provider.expects(:svc).with("-u", "/etc/service/myservice") + + @provider.start + end + + it "should enable the service if it is not enabled" do + @provider.stubs(:svc) + + @provider.expects(:enabled?).returns false @provider.expects(:enable) + @provider.start end end describe "when stopping" do - it "should call disable" do - @provider.expects(:disable) + it "should use 'svc' to stop the service" do + @provider.stubs(:disable) + @provider.expects(:svc).with("-d", "/etc/service/myservice") + @provider.stop end end + describe "when restarting" do + it "should use 'svc' to restart the service" do + @provider.expects(:svc).with("-t", "/etc/service/myservice") + + @provider.restart + end + end + describe "when enabling" do it "should create a symlink between daemon dir and service dir" do FileTest.stubs(:symlink?).returns(false) @@ -80,21 +107,19 @@ describe provider_class do end describe "when disabling" do - it "should stop and then remove the symlink between daemon dir and service dir" do + it "should remove the symlink between daemon dir and service dir" do FileTest.stubs(:directory?).returns(false) FileTest.stubs(:symlink?).returns(true) - File.expects(:unlink).with(File.join(@servicedir,"myservice")).returns(0) + File.expects(:unlink).with(File.join(@servicedir,"myservice")) @provider.stubs(:texecute).returns("") @provider.disable end - end - describe "when disabling" do - it "should also call 'svc -dx /etc/service/myservice'" do + it "should stop the service" do FileTest.stubs(:directory?).returns(false) FileTest.stubs(:symlink?).returns(true) - File.expects(:unlink).with(File.join(@servicedir,"myservice")).returns(0) - @provider.expects(:texecute).with("stop", [nil, '-dx', File.join(@servicedir,"myservice")]).returns "" + File.stubs(:unlink) + @provider.expects(:stop) @provider.disable end end |
