summaryrefslogtreecommitdiffstats
path: root/spec/unit/application.rb
diff options
context:
space:
mode:
authorEthan Rowe <ethan@endpoint.com>2009-07-30 14:09:26 -0400
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitedbe9b6a988932c4b91dd194bc00ca201626d0ae (patch)
tree9d952872b641f1a01bd8d26ea02d149017f52dd7 /spec/unit/application.rb
parent2cf647c34f5e71fc30fccb2de0c5acef5799b924 (diff)
downloadpuppet-edbe9b6a988932c4b91dd194bc00ca201626d0ae.tar.gz
puppet-edbe9b6a988932c4b91dd194bc00ca201626d0ae.tar.xz
puppet-edbe9b6a988932c4b91dd194bc00ca201626d0ae.zip
Fix 2239 (step two): introduce Puppet::Application.controlled_run method to provide simple status-restricted execution of a passed in block; this can replace the process status checks and properly handle delayed restart behavior for Puppet::Agent.
Diffstat (limited to 'spec/unit/application.rb')
-rwxr-xr-xspec/unit/application.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/unit/application.rb b/spec/unit/application.rb
index cc8f79174..87a90099a 100755
--- a/spec/unit/application.rb
+++ b/spec/unit/application.rb
@@ -125,14 +125,42 @@ describe Puppet::Application do
end
end
- describe 'when working with class-level run status properties' do
- it 'should set run status and predicate appropriately on stop!' do
+ describe 'when performing a controlled_run' do
+ it 'should not execute block if not :clear?' do
+ Puppet::Application.run_status = :stop_requested
+ target = mock 'target'
+ target.expects(:some_method).never
+ Puppet::Application.controlled_run do
+ target.some_method
+ end
end
- it 'should set run status and predicate appropriately on restart!' do
+ it 'should execute block if :clear?' do
+ Puppet::Application.run_status = nil
+ target = mock 'target'
+ target.expects(:some_method).once
+ Puppet::Application.controlled_run do
+ target.some_method
+ end
end
+ it 'should signal process with HUP after block if restart requested during block execution' do
+ Puppet::Application.run_status = nil
+ target = mock 'target'
+ target.expects(:some_method).once
+ old_handler = trap('HUP') { target.some_method }
+ begin
+ Puppet::Application.controlled_run do
+ Puppet::Application.run_status = :restart_requested
+ end
+ ensure
+ trap('HUP', old_handler)
+ end
+ end
+ after :each do
+ Puppet::Application.run_status = nil
+ end
end
describe "when parsing command-line options" do