Sha256: 346499d97c442319e0fdd624fc2ac5beea3e07442f17e6af5e0287aad9af8602

Contents?: true

Size: 1.38 KB

Versions: 20

Compression:

Stored size: 1.38 KB

Contents

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

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

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

  def tag
    "tag"
  end

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

  def test_config_params
    d = create_driver
    assert_equal "\t", d.instance.delimiter
    assert_equal  ":", d.instance.label_delimiter

    d = create_driver(
      'delimiter'       => ',',
      'label_delimiter' => '=',
    )

    assert_equal ",", d.instance.delimiter
    assert_equal "=", d.instance.label_delimiter
  end

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

    assert_equal("message:awesome\tgreeting:hello\n", formatted)
  end

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

    assert_equal("message:awesome\tgreeting:hello", formatted)
  end

  def test_format_with_customized_delimiters
    d = create_driver(
      'delimiter'       => ',',
      'label_delimiter' => '=',
    )
    formatted = d.instance.format(tag, @time, record)

    assert_equal("message=awesome,greeting=hello\n", formatted)
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
fluentd-hubspot-0.14.14.2 test/plugin/test_formatter_ltsv.rb
fluentd-hubspot-0.14.14.1 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.21 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.20 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.20.rc1 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.19 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.18 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.17-x86-mingw32 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.17-x64-mingw32 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.17 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.16 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.15 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.14 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.14.pre.1 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.13-x86-mingw32 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.13-x64-mingw32 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.13 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.12-x64-mingw32 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.12-x86-mingw32 test/plugin/test_formatter_ltsv.rb
fluentd-0.14.12 test/plugin/test_formatter_ltsv.rb