Sha256: e0c5f3acb524c6b514c94cedbba47b853cd1924dd812d559ce69b9792834fc9b

Contents?: true

Size: 1.01 KB

Versions: 116

Compression:

Stored size: 1.01 KB

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

  data("newline (LF)" => ["lf", "\n"],
       "newline (CRLF)" => ["crlf", "\r\n"])
  def test_format(data)
    newline_conf, newline = data
    d = create_driver({"newline" => newline_conf})
    formatted = d.instance.format(tag, @time, record)

    assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}#{newline}!, 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

116 entries across 116 versions & 7 rubygems

Version Path
fluentd-1.16.7-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.16.7-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.16.7-x64-mingw-ucrt test/plugin/test_formatter_hash.rb
fluentd-1.16.7 test/plugin/test_formatter_hash.rb
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_formatter_hash.rb
fluentd-1.16.6-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.16.6-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.16.6-x64-mingw-ucrt test/plugin/test_formatter_hash.rb
fluentd-1.16.6 test/plugin/test_formatter_hash.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_formatter_hash.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_formatter_hash.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin/test_formatter_hash.rb
fluentd-1.17.0-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.17.0-x64-mingw-ucrt test/plugin/test_formatter_hash.rb
fluentd-1.17.0-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.17.0 test/plugin/test_formatter_hash.rb
fluentd-1.16.5-x64-mingw-ucrt test/plugin/test_formatter_hash.rb
fluentd-1.16.5-x86-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.16.5-x64-mingw32 test/plugin/test_formatter_hash.rb
fluentd-1.16.5 test/plugin/test_formatter_hash.rb