ext/revdispatch/stest.rb in evdispatch-0.2.2 vs ext/revdispatch/stest.rb in evdispatch-0.2.4
- old
+ new
@@ -1,9 +1,9 @@
-$:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
+require 'test/unit'
+$:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
require 'evdispatch'
-require 'test/unit'
$d = Evdispatch::Loop.new
# start the event loop thread
$d.start
@@ -27,18 +27,24 @@
assert_match(/ 302 Moved Temporarily/,response[:header])
assert_match(/ 200 OK/,response[:header])
end
def test_delayed_with_flush
- id = $d.request("http://127.0.0.1:4044/delay/0")
- tid = $d.request("http://127.0.0.1:4044/delay/3")
- res = $d.response( id, 1.0, 1 )
- res2 = $d.response( tid, 1.0, 1 )
+ id = $d.request("http://127.0.0.1:4044/delay/0.1")
+ tid = $d.request("http://127.0.0.1:4044/delay/3.0")
+ res = $d.blocking_response_for( id, :timeout => 0.5 )
+ res2 = $d.blocking_response_for( tid, :timeout => 0.5 )#, 1.0, 1 )
if !res or !res2
$d.flush # flush because we aborted before we finished, still the issue of the request is still running, but any previous responses that were delayed will be flushed
end
- puts res.inspect
- puts res2.inspect
+ assert_not_nil res
+ assert_nil res2
+ end
+
+ def test_post
+ id = $d.request("http://127.0.0.1:4044/test_post_length", :post => "hello there world")
+ res = $d.blocking_response_for( id )
+ assert_not_nil res
end
end
# not bothering to cleanup