2017-05-12 15:16:55 -04:00
|
|
|
require_relative "helper"
|
2016-06-06 09:18:28 -04:00
|
|
|
|
2016-11-22 10:05:49 -05:00
|
|
|
require "puma/tcp_logger"
|
2016-06-06 09:18:28 -04:00
|
|
|
|
2016-08-31 15:53:55 -04:00
|
|
|
class TestTCPLogger < Minitest::Test
|
2016-06-06 09:18:28 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
@events = Puma::Events.new STDOUT, STDERR
|
|
|
|
@server = Puma::Server.new nil, @events
|
|
|
|
|
|
|
|
@server.app = proc { |env, socket|}
|
|
|
|
@server.tcp_mode!
|
|
|
|
|
|
|
|
@socket = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_events
|
|
|
|
# in lib/puma/launcher.rb:85
|
|
|
|
# Puma::Events is default tcp_logger for cluster mode
|
|
|
|
logger = Puma::Events.new(STDOUT, STDERR)
|
|
|
|
out, err = capture_subprocess_io do
|
|
|
|
Puma::TCPLogger.new(logger, @server.app).call({}, @socket)
|
|
|
|
end
|
|
|
|
assert_match(/connected/, out)
|
|
|
|
assert_equal('', err)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_io
|
|
|
|
# in lib/puma/configuration.rb:184
|
|
|
|
# STDOUT is default tcp_logger for single mode
|
|
|
|
logger = STDOUT
|
|
|
|
out, err = capture_subprocess_io do
|
|
|
|
Puma::TCPLogger.new(logger, @server.app).call({}, @socket)
|
|
|
|
end
|
|
|
|
assert_match(/connected/, out)
|
|
|
|
assert_equal('', err)
|
|
|
|
end
|
|
|
|
end
|