Sha256: 8fb32f0ac0d07230e08763454bed51405c2eb05c1c775f4e8a75668d586ac8b7
Contents?: true
Size: 1.73 KB
Versions: 14
Compression:
Stored size: 1.73 KB
Contents
require_relative '../helper' require 'fluent/test/driver/parser' require 'fluent/plugin/parser' class NoneParserTest < ::Test::Unit::TestCase def setup Fluent::Test.setup end def test_config_params parser = Fluent::Test::Driver::Parser.new(Fluent::TextParser::NoneParser) parser.configure({}) assert_equal "message", parser.instance.message_key parser.configure('message_key' => 'foobar') assert_equal "foobar", parser.instance.message_key end def test_parse parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('none')) parser.configure({}) parser.instance.parse('log message!') { |time, record| assert_equal({'message' => 'log message!'}, record) } end def test_parse_with_message_key parser = Fluent::Test::Driver::Parser.new(Fluent::TextParser::NoneParser) parser.configure('message_key' => 'foobar') parser.instance.parse('log message!') { |time, record| assert_equal({'foobar' => 'log message!'}, record) } end def test_parse_without_default_time time_at_start = Time.now.to_i parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('none')) parser.configure({}) parser.instance.parse('log message!') { |time, record| assert time && time >= time_at_start, "parser puts current time without time input" assert_equal({'message' => 'log message!'}, record) } parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('none')) parser.instance.estimate_current_event = false parser.configure({}) parser.instance.parse('log message!') { |time, record| assert_equal({'message' => 'log message!'}, record) assert_nil time, "parser returns nil w/o time if configured so" } end end
Version data entries
14 entries across 14 versions & 1 rubygems