# test/plugin/test_formatter_your_own.rb
require 'fluent/test/driver/formatter'
require 'fluent/plugin/formatter_your_own'
class FormatterYourOwnTest < Test::Unit::TestCase
def create_driver(conf = CONF)
Fluent::Test::Driver::Formatter.new(Fluent::Plugin::YourOwnFormatter).configure(conf)
sub_test_case 'configured with invalid configurations' do
assert_raise(Fluent::ConfigError) do
sub_test_case 'plugin will format record' do
test 'record has a field' do
d = create_driver(CONFIG)
record = { 'message' => 'This is message' }
formatted = d.instance.format(tag, time, record)
assert_equal(expected, formatted)