Skip to content

Commit

Permalink
PluginHelper::EventEmitter: Add tests for event_emitter_router
Browse files Browse the repository at this point in the history
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
  • Loading branch information
ashie committed Jul 21, 2021
1 parent 968ff28 commit 3c60b95
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/plugin_helper/test_event_emitter.rb
@@ -1,6 +1,7 @@
require_relative '../helper'
require 'fluent/plugin_helper/event_emitter'
require 'fluent/plugin/base'
require 'flexmock/test_unit'

class EventEmitterTest < Test::Unit::TestCase
setup do
Expand Down Expand Up @@ -48,4 +49,32 @@ class Dummy < Fluent::Plugin::TestBase

d1.terminate
end

test 'should not have event_emitter_router' do
d0 = Dummy0.new
assert !d0.respond_to?(:event_emitter_router)
end

test 'should have event_emitter_router' do
d0 = Dummy.new
assert d0.respond_to?(:event_emitter_router)
end

test 'get router' do
router_mock = flexmock('mytest')
label_mock = flexmock('mylabel')
label_mock.should_receive(:event_router).twice.and_return(router_mock)
Fluent::Engine.root_agent.labels['@mytest'] = label_mock

d = Dummy.new
d.configure(config_element('ROOT', '', {'@label' => '@mytest'}))
router = d.event_emitter_router("@mytest")
assert_equal router_mock, router
end

test 'get root router' do
d = Dummy.new
router = d.event_emitter_router("@ROOT")
assert_equal Fluent::Engine.root_agent.event_router, router
end
end

0 comments on commit 3c60b95

Please sign in to comment.