require_relative 'helper' require 'fluent/fluent_log_event_router' require 'fluent/root_agent' require 'fluent/system_config' class FluentLogEventRouterTest < ::Test::Unit::TestCase # @param config [String] def build_config(config) Fluent::Config.parse(config, 'fluent_log_event', '', syntax: :v1) end sub_test_case 'NullFluentLogEventRouter does nothing' do test 'emittable? returns false but others does nothing' do null_event_router = Fluent::NullFluentLogEventRouter.new null_event_router.start null_event_router.stop null_event_router.graceful_stop null_event_router.emit_event(nil) assert_false null_event_router.emittable? end end sub_test_case '#build' do test 'NullFluentLogEventRouter if root_agent have not internal logger' do root_agent = Fluent::RootAgent.new(log: $log, system_config: Fluent::SystemConfig.new) root_agent.configure(build_config('')) d = Fluent::FluentLogEventRouter.build(root_agent) assert_equal Fluent::NullFluentLogEventRouter, d.class end test 'FluentLogEventRouter if exists in config' do root_agent = Fluent::RootAgent.new(log: $log, system_config: Fluent::SystemConfig.new) root_agent.configure(build_config(<<-CONFIG)) @type null CONFIG d = Fluent::FluentLogEventRouter.build(root_agent) assert_equal Fluent::FluentLogEventRouter, d.class end test 'FluentLogEventRouter if