Skip to content

Commit

Permalink
Adding spec test for dead process
Browse files Browse the repository at this point in the history
  • Loading branch information
hunner committed Oct 21, 2011
1 parent 00315c2 commit 88d3400
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions agent/puppetd/spec/puppetd_agent_spec.rb
Expand Up @@ -149,6 +149,19 @@
result.should be_successful
end

it "with puppet agent stopped but PID file present" do
File.expects(:exists?).with("spec_test_lock_file").returns(false)
File.expects(:exists?).with("spec_test_pid_file").returns(true)
File.expects(:read).with("spec_test_pid_file").returns("99999999\n")
::Process.expects(:kill).with(0, 99999999).raises(Errno::ESRCH)
::Process.expects(:kill).with("USR1", 99999999).never
@agent.instance_variable_set("@puppetd", "spec_test_puppetd")
@agent.expects(:run).with("spec_test_puppetd --onetime", :stdout => :output, :chomp => true)
result = @agent.call(:runonce)
result[:statusmsg].should == "OK"
result.should be_successful
end

it "with PID file containing rubbish" do
File.expects(:exists?).with("spec_test_lock_file").returns(false)
File.expects(:exists?).with("spec_test_pid_file").returns(true)
Expand Down

0 comments on commit 88d3400

Please sign in to comment.