about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-24 15:41:53 -0800
committerEric Wong <normalperson@yhbt.net>2010-12-24 15:48:18 -0800
commit2816f3ceaa31452f6bb67a7a7297e6795221cb35 (patch)
tree3f3ed0229d2ce15e8287c513a2efa2a6fb47012f /test
parent9b46379f75f384c86e42046ab03ce55231197c92 (diff)
downloadclogger-2816f3ceaa31452f6bb67a7a7297e6795221cb35.tar.gz
This lets us use CLOCK_MONOTONIC so we are not affected by
system clock changes.

We still convert to microseconds instead of nanoseconds for
(pure)-Ruby 1.8 code compatibility.  There is also little need
for nanosecond timer resolution in log files (microsecond is not
needed, even).
Diffstat (limited to 'test')
-rw-r--r--test/test_clogger.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/test_clogger.rb b/test/test_clogger.rb
index 9252a42..47387bb 100644
--- a/test/test_clogger.rb
+++ b/test/test_clogger.rb
@@ -647,4 +647,14 @@ class TestClogger < Test::Unit::TestCase
       Clogger.new(app, :logger=> $stderr, :path => tmp.path)
     }
   end
+
+  def test_request_time
+    s = []
+    app = lambda { |env| sleep(0.1) ; [302, [], [] ] }
+    cl = Clogger.new(app, :logger => s, :format => "$request_time")
+    status, headers, body = cl.call(@req)
+    assert_nothing_raised { body.each { |x| } ; body.close }
+    assert s[-1].to_f >= 0.100
+    assert s[-1].to_f <= 0.110
+  end
 end