Sha256: 0eb9bab884764af1633160164ac211459022234a1f00a4da2cbd0843ae829e72

Contents?: true

Size: 1.8 KB

Versions: 15

Compression:

Stored size: 1.8 KB

Contents

require_relative '../helper'
require 'fluent/plugin/base'

module FluentPluginBaseTest
  class DummyPlugin < Fluent::Plugin::Base
  end
end

class BaseTest < Test::Unit::TestCase
  setup do
    @p = FluentPluginBaseTest::DummyPlugin.new
  end

  test 'has methods for phases of plugin life cycle, and methods to know "super"s were correctly called or not' do
    assert !@p.configured?
    @p.configure(config_element())
    assert @p.configured?

    assert !@p.started?
    @p.start
    assert @p.start

    assert !@p.stopped?
    @p.stop
    assert @p.stopped?

    assert !@p.before_shutdown?
    @p.before_shutdown
    assert @p.before_shutdown?

    assert !@p.shutdown?
    @p.shutdown
    assert @p.shutdown?

    assert !@p.after_shutdown?
    @p.after_shutdown
    assert @p.after_shutdown?

    assert !@p.closed?
    @p.close
    assert @p.closed?

    assert !@p.terminated?
    @p.terminate
    assert @p.terminated?
  end

  test 'can access system config' do
    assert @p.system_config

    @p.system_config_override({'process_name' => 'mytest'})
    assert_equal 'mytest', @p.system_config.process_name
  end

  test 'does not have router in default' do
    assert !@p.has_router?
  end

  test 'is configurable by config_param and config_section' do
    assert_nothing_raised do
      class FluentPluginBaseTest::DummyPlugin2 < Fluent::Plugin::TestBase
        config_param :myparam1, :string
        config_section :mysection, multi: false do
          config_param :myparam2, :integer
        end
      end
    end
    p2 = FluentPluginBaseTest::DummyPlugin2.new
    assert_nothing_raised do
      p2.configure(config_element('ROOT', '', {'myparam1' => 'myvalue1'}, [config_element('mysection', '', {'myparam2' => 99})]))
    end
    assert_equal 'myvalue1', p2.myparam1
    assert_equal 99, p2.mysection.myparam2
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fluentd-0.14.8 test/plugin/test_base.rb
fluentd-0.14.7-x64-mingw32 test/plugin/test_base.rb
fluentd-0.14.7-x86-mingw32 test/plugin/test_base.rb
fluentd-0.14.7 test/plugin/test_base.rb
fluentd-0.14.6 test/plugin/test_base.rb
fluentd-0.14.5-x64-mingw32 test/plugin/test_base.rb
fluentd-0.14.5-x86-mingw32 test/plugin/test_base.rb
fluentd-0.14.5 test/plugin/test_base.rb
fluentd-0.14.4-x64-mingw32 test/plugin/test_base.rb
fluentd-0.14.4-x86-mingw32 test/plugin/test_base.rb
fluentd-0.14.4 test/plugin/test_base.rb
fluentd-0.14.3 test/plugin/test_base.rb
fluentd-0.14.2 test/plugin/test_base.rb
fluentd-0.14.1 test/plugin/test_base.rb
fluentd-0.14.0 test/plugin/test_base.rb