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-1.11.4-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.4-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.4 test/plugin/test_formatter_hash.rb
fluentd-1.11.3-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.3-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.3 test/plugin/test_formatter_hash.rb
fluentd-1.11.2-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.2-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.2 test/plugin/test_formatter_hash.rb
fluentd-1.11.1-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.1-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.1 test/plugin/test_formatter_hash.rb
fluentd-1.11.0-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.0-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.11.0 test/plugin/test_formatter_hash.rb
fluentd-1.10.4-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.10.4-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.10.4 test/plugin/test_formatter_hash.rb
fluentd-1.10.3-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.10.3-x86-mingw32 test/plugin/test_formatter_hash.rb