Sha256: cc59ef6b51da3ee6557143d252f38f7345959f6499d1098877720ae44a583dba
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
require "./test/helper" class TestHitNRun < Test::Unit::TestCase def setup @addr, @port, @srv = start_server("./test/sha1.ru", 1) @sockaddr = Socket.pack_sockaddr_in(@port, @addr) @env = { "REQUEST_METHOD" => "PUT", "REQUEST_URI" => "/", "HTTP_HOST" => "example.com", } @tmpfiles = [] end def teardown Process.kill(:QUIT, @srv) Process.waitpid2(@srv) @tmpfiles.each { |tmp| tmp.closed? or tmp.close! } end def test_request_with_existing_socket sock = Kgio::Socket.new(@sockaddr) req = HTTP_Spew::HitNRun.new(@env, nil, sock) assert_equal sock, req.to_io assert_nothing_raised { req.close } assert sock.closed? end def test_request_single req = HTTP_Spew::HitNRun.new(@env, nil, @sockaddr) sym = req.resume if sym == :wait_writable set = Kgio.poll({req => sym}, 100) assert_equal [ req ], set.keys sym = req.resume end assert_equal HTTP_Spew::HitNRun::RESPONSE.object_id, sym.object_id end def test_request_loop req = HTTP_Spew::HitNRun.new(@env, nil, @sockaddr) until Array === (rv = req.resume) Kgio.poll(req => rv) end assert_equal HTTP_Spew::HitNRun::RESPONSE.object_id, rv.object_id end end
Version data entries
5 entries across 5 versions & 1 rubygems