summaryrefslogtreecommitdiffstats
path: root/spec/unit/application.rb
diff options
context:
space:
mode:
authorEthan Rowe <ethan@endpoint.com>2009-07-30 01:17:01 -0400
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit2cf647c34f5e71fc30fccb2de0c5acef5799b924 (patch)
tree3d0cae1bebdd3f8c129771b8a5e2340620ab9447 /spec/unit/application.rb
parentce944a5d9ae7b18a2557eb282ac20e4ff49ce6f3 (diff)
downloadpuppet-2cf647c34f5e71fc30fccb2de0c5acef5799b924.tar.gz
puppet-2cf647c34f5e71fc30fccb2de0c5acef5799b924.tar.xz
puppet-2cf647c34f5e71fc30fccb2de0c5acef5799b924.zip
Fix 2239 (step one): introduce global settings represeting application run state with methods for
setting the state and appropriately-named predicates for querying state, all in the Puppet::Application class itself. To be used by Puppet::Daemon and Puppet::Agent and Puppet::Transaction for better response to TERM, INT, HUP.
Diffstat (limited to 'spec/unit/application.rb')
-rwxr-xr-xspec/unit/application.rb99
1 files changed, 99 insertions, 0 deletions
diff --git a/spec/unit/application.rb b/spec/unit/application.rb
index c087373ac..cc8f79174 100755
--- a/spec/unit/application.rb
+++ b/spec/unit/application.rb
@@ -36,6 +36,105 @@ describe Puppet::Application do
@app.get_command.should == :main
end
+ describe 'when invoking clear!' do
+ before :each do
+ Puppet::Application.run_status = :stop_requested
+ Puppet::Application.clear!
+ end
+
+ it 'should have nil run_status' do
+ Puppet::Application.run_status.should be_nil
+ end
+
+ it 'should return false for restart_requested?' do
+ Puppet::Application.restart_requested?.should be_false
+ end
+
+ it 'should return false for stop_requested?' do
+ Puppet::Application.stop_requested?.should be_false
+ end
+
+ it 'should return false for interrupted?' do
+ Puppet::Application.interrupted?.should be_false
+ end
+
+ it 'should return true for clear?' do
+ Puppet::Application.clear?.should be_true
+ end
+ end
+
+ describe 'after invoking stop!' do
+ before :each do
+ Puppet::Application.run_status = nil
+ Puppet::Application.stop!
+ end
+
+ after :each do
+ Puppet::Application.run_status = nil
+ end
+
+ it 'should have run_status of :stop_requested' do
+ Puppet::Application.run_status.should == :stop_requested
+ end
+
+ it 'should return true for stop_requested?' do
+ Puppet::Application.stop_requested?.should be_true
+ end
+
+ it 'should return false for restart_requested?' do
+ Puppet::Application.restart_requested?.should be_false
+ end
+
+ it 'should return true for interrupted?' do
+ Puppet::Application.interrupted?.should be_true
+ end
+
+ it 'should return false for clear?' do
+ Puppet::Application.clear?.should be_false
+ end
+ end
+
+ describe 'when invoking restart!' do
+ before :each do
+ Puppet::Application.run_status = nil
+ Puppet::Application.restart!
+ end
+
+ after :each do
+ Puppet::Application.run_status = nil
+ end
+
+ it 'should have run_status of :restart_requested' do
+ Puppet::Application.run_status.should == :restart_requested
+ end
+
+ it 'should return true for restart_requested?' do
+ Puppet::Application.restart_requested?.should be_true
+ end
+
+ it 'should return false for stop_requested?' do
+ Puppet::Application.stop_requested?.should be_false
+ end
+
+ it 'should return true for interrupted?' do
+ Puppet::Application.interrupted?.should be_true
+ end
+
+ it 'should return false for clear?' do
+ Puppet::Application.clear?.should be_false
+ end
+ end
+
+ describe 'when working with class-level run status properties' do
+ it 'should set run status and predicate appropriately on stop!' do
+ end
+
+ it 'should set run status and predicate appropriately on restart!' do
+ end
+
+
+ end
+
describe "when parsing command-line options" do
before :each do