Sha256: e340151f8a078da5da03b00b152562e9b7908002c22b4f787da941ed7b13e303

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

require 'helper'

class TestTimeLocal < Test::Unit::TestCase

  context "ntail" do

    setup do
      @time_local = "13/Apr/2010:04:45:51 +0100"
      @log_line = random_log_line(:time_local => @time_local)
    end

    should "parse local time (in the common log format) into a date object" do
      # directly via the helper function
      to_date = NginxTail::LogLine.to_date(@time_local)
      assert_equal "2010-04-13T04:45:51+01:00", to_date.to_s
      # parsed from a raw log line
      assert_equal "2010-04-13T04:45:51+01:00", @log_line.to_date.to_s
    end

    should "parse and format local time (in the common log format) into a date string" do
      # directly via the helper function
      to_date_s = NginxTail::LogLine.to_date_s(@time_local)
      assert_equal "2010-04-13 04:45:51", to_date_s
      # parsed from a raw log line
      assert_equal "2010-04-13 04:45:51", @log_line.to_date_s
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ntail-1.3.2 test/ntail/test_time_local.rb