Sha256: a202f9e11bc9ec5087aa4c374d0710fde12c0143af3138bee16a7bf13d90c0ba
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'helper' require 'fluent/plugin/out_record_serializer' require 'yaml' class RecordSerializerOutputTest < Test::Unit::TestCase def setup Fluent::Test.setup end TAG = 'test.serialize' FORMAT = 'json' FIELD_NAME = 'payload' CONFIG = %[ tag #{TAG} ] YAML_CONFIG = %[ tag #{TAG} format yaml ] def create_driver(conf=CONFIG) Fluent::Test::OutputTestDriver.new(Fluent::RecordSerializerOutput).configure(conf) end def test_configure d = create_driver assert_equal FORMAT, d.instance.format assert_equal FIELD_NAME, d.instance.field_name end def test_json record = {'spam' => 1, 'ham' => 'egg',} d = create_driver d.run do d.emit(record) end assert_equal [{'tag' => TAG, FIELD_NAME => record.to_json}], d.records end def test_yaml record = {'spam' => 1, 'ham' => 'egg',} d = create_driver YAML_CONFIG d.run do d.emit(record) end assert_equal [{'tag' => TAG, FIELD_NAME => record.to_yaml}], d.records end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-record-serializer-0.1.0 | test/plugin/test_out_record_serializer.rb |