class TestLogger

Public Instance Methods

test_logger() click to toggle source
# File vendor/qwik/lib/qwik/logger.rb, line 87
def test_logger
  c = Qwik::Logger

  # test_format_log_line
  config = Qwik::Config.new
  req = Qwik::Request.new(config)
  res = Qwik::Response.new(config)
  assert_equal "1970-01-01T09:00:00  - \"\" 200 - 0.00\n",
    c.format_log_line(req, res, 0)

  path = 'test.txt'.path
  path.unlink if path.exist?

  # test_init
  logger = Qwik::Logger.new(path.to_s)
  assert_equal true, path.exist?

  # test_log
  logger.log(req, res, req, res, 0)
  assert_equal "1970-01-01T09:00:00  - \"\" 200 - 0.00\n", path.read

  # test_close
  logger.close

  path.unlink if path.exist?
  assert_equal false, path.exist?
end