1 # -*- encoding: binary -*-
6 $stderr.sync = $stdout.sync = true
8 class TestLinuxMiddleware < Test::Unit::TestCase
11 @resp_headers = { 'Content-Type' => 'text/plain', 'Content-Length' => '0' }
12 @response = [ 200, @resp_headers, [] ]
13 @app = lambda { |env| @response }
16 def test_unix_listener
17 tmp = Tempfile.new("")
19 us = UNIXServer.new(tmp.path)
20 app = Raindrops::Middleware.new(@app, :listeners => [tmp.path])
21 linux_extra = "#{tmp.path} active: 0\n#{tmp.path} queued: 0\n"
22 response = app.call("PATH_INFO" => "/_raindrops")
27 "Content-Type" => "text/plain",
28 "Content-Length" => (22 + linux_extra.size).to_s
31 "calling: 0\nwriting: 0\n#{linux_extra}" \
34 assert_equal expect, response
37 def test_unix_listener_queued
38 tmp = Tempfile.new("")
40 us = UNIXServer.new(tmp.path)
41 uc = UNIXSocket.new(tmp.path)
42 app = Raindrops::Middleware.new(@app, :listeners => [tmp.path])
43 linux_extra = "#{tmp.path} active: 0\n#{tmp.path} queued: 1\n"
44 response = app.call("PATH_INFO" => "/_raindrops")
49 "Content-Type" => "text/plain",
50 "Content-Length" => (22 + linux_extra.size).to_s
53 "calling: 0\nwriting: 0\n#{linux_extra}" \
56 assert_equal expect, response
59 end if RUBY_PLATFORM =~ /linux/