Permalink
Browse files

Update fcgi dispatcher test cases. Closes #11471 [guillaume]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9220 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 940cf0c commit cfe42ba1b19c5ee96a268dbb85cece16c0cc354b @jeremy jeremy committed Apr 3, 2008
Showing with 23 additions and 7 deletions.
  1. +23 −7 railties/test/fcgi_dispatcher_test.rb
@@ -59,11 +59,12 @@ def test_process_with_system_exit_exception
@handler.process!
end
- def test_restart_handler
+ def test_restart_handler_outside_request
@handler.expects(:dispatcher_log).with(:info, "asked to restart ASAP")
+ @handler.expects(:restart!).once
@handler.send(:restart_handler, nil)
- assert_equal :restart, @handler.when_ready
+ assert_equal nil, @handler.when_ready
end
def test_install_signal_handler_should_log_on_bad_signal
@@ -131,7 +132,7 @@ def setup
def test_interrupted_via_HUP_when_not_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- @handler.expects(:gc_countdown).returns { Process.kill 'HUP', $$ }
+ @handler.expects(:gc_countdown).returns(lambda { Process.kill 'HUP', $$ } )
@handler.expects(:reload!).once
@handler.expects(:close_connection).never
@@ -144,7 +145,7 @@ def test_interrupted_via_HUP_when_not_in_request
def test_interrupted_via_HUP_when_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'HUP', $$ }
+ Dispatcher.expects(:dispatch).with(cgi).returns( lambda { Process.kill 'HUP', $$ } )
@handler.expects(:reload!).once
@handler.expects(:close_connection).never
@@ -157,7 +158,7 @@ def test_interrupted_via_HUP_when_in_request
def test_interrupted_via_USR1_when_not_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- @handler.expects(:gc_countdown).returns { Process.kill 'USR1', $$ }
+ @handler.expects(:gc_countdown).returns( lambda { Process.kill 'USR1', $$ } )
@handler.expects(:exit_handler).never
@handler.expects(:reload!).never
@@ -171,7 +172,7 @@ def test_interrupted_via_USR1_when_not_in_request
def test_interrupted_via_USR1_when_in_request
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'USR1', $$ }
+ Dispatcher.expects(:dispatch).with(cgi).returns( lambda { Process.kill 'USR1', $$ } )
@handler.expects(:reload!).never
@handler.expects(:close_connection).with(cgi).once
@@ -181,10 +182,25 @@ def test_interrupted_via_USR1_when_in_request
assert_equal :exit, @handler.when_ready
end
+ def test_restart_via_USR2_when_in_request
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ @handler.expects(:gc_countdown).returns( lambda { Process.kill 'USR2', $$ } )
+ @handler.expects(:exit_handler).never
+
+ @handler.expects(:reload!).never
+ @handler.expects(:close_connection).with(cgi).once
+ @handler.expects(:exit).never
+ @handler.expects(:restart!).once
+
+ @handler.process!
+ assert_equal :restart, @handler.when_ready
+ end
+
def test_interrupted_via_TERM
cgi = mock
FCGI.expects(:each_cgi).once.yields(cgi)
- Dispatcher.expects(:dispatch).with(cgi).returns { Process.kill 'TERM', $$ }
+ Dispatcher.expects(:dispatch).with(cgi).returns(lambda { Process.kill 'TERM', $$ })
@handler.expects(:reload!).never
@handler.expects(:close_connection).never

0 comments on commit cfe42ba

Please sign in to comment.