Sha256: 512cd213920758b0b4b282481da5b072771551997fef6391fcc5a839915464e9
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
require 'fluent/config' require 'fluent/test' require 'fluent/test/driver/parser' require 'fluent/plugin/parser' require 'fluent/plugin/parser_multi_format' require 'test/unit' class MultiFormatParserTest < ::Test::Unit::TestCase def setup Fluent::Test.setup end def create_driver(conf) conf = Fluent::Config.parse(conf, "(test)", "(test_dir)", true) Fluent::Test::Driver::Parser.new(Fluent::Plugin::MultiFormatParser.new).configure(conf) end def test_configure conf = %[ @type multi_format <pattern> format apache </pattern> <pattern> format json time_key timestamp </pattern> <pattern> format none </pattern> ] d = create_driver(conf) parsers = d.instance.instance_variable_get(:@parsers) assert_instance_of(Fluent::Plugin::ApacheParser, parsers[0]) assert_instance_of(Fluent::Plugin::JSONParser, parsers[1]) assert_instance_of(Fluent::Plugin::NoneParser, parsers[2]) end def test_parse conf = %[ @type multi_format <pattern> format apache </pattern> <pattern> format json time_key timestamp </pattern> <pattern> format none </pattern> ] d = create_driver(conf) d.instance.parse('{"k":"v"}') { |t, r| assert_equal({"k" => "v"}, r) } d.instance.parse('hello') { |t, r| assert_equal({"message" => "hello"}, r) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-multi-format-parser-1.1.0 | test/test_parser_multi_format.rb |