Sha256: 35933db153140c38b568ef51d77e037f3870915517bef95b6d76abb021d40a22

Contents?: true

Size: 878 Bytes

Versions: 155

Compression:

Stored size: 878 Bytes

Contents

require_relative '../helper'
require 'fluent/test/driver/formatter'
require 'fluent/plugin/formatter_hash'

class HashFormatterTest < ::Test::Unit::TestCase
  def setup
    @time = event_time
  end

  def create_driver(conf = "")
    Fluent::Test::Driver::Formatter.new(Fluent::Plugin::HashFormatter).configure(conf)
  end

  def tag
    "tag"
  end

  def record
    {'message' => 'awesome', 'greeting' => 'hello'}
  end

  def test_format
    d = create_driver({})
    formatted = d.instance.format(tag, @time, record)

    assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}\n!, formatted.encode(Encoding::UTF_8))
  end

  def test_format_without_newline
    d = create_driver('add_newline' => false)
    formatted = d.instance.format(tag, @time, record)

    assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}!, formatted.encode(Encoding::UTF_8))
  end
end

Version data entries

155 entries across 155 versions & 2 rubygems

Version Path
fluentd-0.14.19 test/plugin/test_formatter_hash.rb
fluentd-0.14.18 test/plugin/test_formatter_hash.rb
fluentd-0.14.17-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-0.14.17-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-0.14.17 test/plugin/test_formatter_hash.rb
fluentd-0.14.16 test/plugin/test_formatter_hash.rb
fluentd-0.14.15 test/plugin/test_formatter_hash.rb
fluentd-0.14.14 test/plugin/test_formatter_hash.rb
fluentd-0.14.14.pre.1 test/plugin/test_formatter_hash.rb
fluentd-0.14.13-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-0.14.13-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-0.14.13 test/plugin/test_formatter_hash.rb
fluentd-0.14.12-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-0.14.12-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-0.14.12 test/plugin/test_formatter_hash.rb