Sha256: 79bbfbf88432bdd1e9d6897bf9ed6ada0a67057bd64a0137846900847a37cec8

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require "helper"
require "fluent/plugin/parser_groonga_log.rb"

class GroongaLogParserTest < Test::Unit::TestCase
  def setup
    Fluent::Test.setup
    @parser = create_driver
    @parser.configure({})
  end

  def test_parse
    log = "2017-07-19 14:41:05.663978|n|18c61700|spec:2:update:Object:32(type):8"
    @parser.instance.parse(log) do |time, record|
      timestamp = Time.local(2017, 7, 19, 14, 41, 5, 663978)
      expected = {
        "year" => 2017,
        "month" => 7,
        "day" => 19,
        "hour" => 14,
        "minute" => 41,
        "second" => 5,
        "micro_second" => 663978,
        "log_level" => :notice,
        "context_id" => "18c61700",
        "message" => "spec:2:update:Object:32(type):8",
      }
      assert_equal([
                     Fluent::EventTime.from_time(timestamp),
                     expected,
                   ],
                   [time, record])
    end
  end

  private
  def create_driver
    Fluent::Test::Driver::Parser.new(Fluent::Plugin::GroongaLogParser)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-groonga-log-0.1.0 test/plugin/test_parser_groonga_log.rb