From 2dd3e22782090dc347429e306569f687fa794d06 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 8 Feb 2010 17:14:41 -0800 Subject: Allow :reentrant flag to be forced true/false Clogger may set this value independently of "rack.multithread" since Actor/Fiber-based servers may have multiple instances of Clogger wrapping different response bodies and yet be incompatible with "rack.multithread" --- test/test_clogger.rb | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'test/test_clogger.rb') diff --git a/test/test_clogger.rb b/test/test_clogger.rb index 1906718..b086bbb 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -545,4 +545,46 @@ class TestClogger < Test::Unit::TestCase assert_equal :foo, body.close end + def test_clogger_auto_reentrant_true + s = '' + body = [] + app = lambda { |env| [302, [ %w(a) ], body ] } + cl = Clogger.new(app, :logger => s, :format => "$request_time") + @req['rack.multithread'] = true + status, headers, body = cl.call(@req) + assert cl.reentrant? + end + + def test_clogger_auto_reentrant_false + s = '' + body = [] + app = lambda { |env| [302, [ %w(a) ], body ] } + cl = Clogger.new(app, :logger => s, :format => "$request_time") + @req['rack.multithread'] = false + status, headers, body = cl.call(@req) + assert ! cl.reentrant? + end + + def test_clogger_auto_reentrant_forced_true + s = '' + body = [] + app = lambda { |env| [302, [ %w(a) ], body ] } + o = { :logger => s, :format => "$request_time", :reentrant => true } + cl = Clogger.new(app, o) + @req['rack.multithread'] = false + status, headers, body = cl.call(@req) + assert cl.reentrant? + end + + def test_clogger_auto_reentrant_forced_false + s = '' + body = [] + app = lambda { |env| [302, [ %w(a) ], body ] } + o = { :logger => s, :format => "$request_time", :reentrant => false } + cl = Clogger.new(app, o) + @req['rack.multithread'] = true + status, headers, body = cl.call(@req) + assert ! cl.reentrant? + end + end -- cgit v1.2.3-24-ge0c7