Sha256: 8b1eaaa2e309563a4056db4f48c07bac00f847a958b3d3d5e1b783f08c6a11ce

Contents?: true

Size: 1.19 KB

Versions: 155

Compression:

Stored size: 1.19 KB

Contents

require_relative '../helper'
require 'json'
require 'fluent/test/driver/formatter'
require 'fluent/plugin/formatter_json'

class JsonFormatterTest < ::Test::Unit::TestCase

  def setup
    @time = event_time
  end

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

  def tag
    "tag"
  end

  def record
    {'message' => 'awesome'}
  end

  def symbolic_record
    {:message => :awesome}
  end

  data('oj' => 'oj', 'yajl' => 'yajl')
  def test_format(data)
    d = create_driver('json_parser' => data)
    formatted = d.instance.format(tag, @time, record)

    assert_equal("#{JSON.generate(record)}\n", formatted)
  end

  data('oj' => 'oj', 'yajl' => 'yajl')
  def test_format_without_nl(data)
    d = create_driver('json_parser' => data, 'add_newline' => false)
    formatted = d.instance.format(tag, @time, record)

    assert_equal(JSON.generate(record), formatted)
  end

  data('oj' => 'oj', 'yajl' => 'yajl')
  def test_format_with_symbolic_record(data)
    d = create_driver('json_parser' => data)
    formatted = d.instance.format(tag, @time, symbolic_record)

    assert_equal("#{JSON.generate(record)}\n", formatted)
  end
end

Version data entries

155 entries across 155 versions & 2 rubygems

Version Path
fluentd-1.1.3 test/plugin/test_formatter_json.rb
fluentd-1.1.2 test/plugin/test_formatter_json.rb
fluentd-1.1.1 test/plugin/test_formatter_json.rb
fluentd-1.1.0 test/plugin/test_formatter_json.rb
fluentd-1.0.2 test/plugin/test_formatter_json.rb
fluentd-1.0.1 test/plugin/test_formatter_json.rb
fluentd-1.0.0 test/plugin/test_formatter_json.rb
fluentd-0.14.25 test/plugin/test_formatter_json.rb
fluentd-1.0.0.rc1 test/plugin/test_formatter_json.rb
fluentd-0.14.24 test/plugin/test_formatter_json.rb
fluentd-0.14.23 test/plugin/test_formatter_json.rb
fluentd-0.14.23.rc1 test/plugin/test_formatter_json.rb
fluentd-0.14.22 test/plugin/test_formatter_json.rb
fluentd-0.14.22.rc2 test/plugin/test_formatter_json.rb
fluentd-hubspot-0.14.14.2 test/plugin/test_formatter_json.rb
fluentd-hubspot-0.14.14.1 test/plugin/test_formatter_json.rb
fluentd-0.14.22.rc1 test/plugin/test_formatter_json.rb
fluentd-0.14.21 test/plugin/test_formatter_json.rb
fluentd-0.14.20 test/plugin/test_formatter_json.rb
fluentd-0.14.20.rc1 test/plugin/test_formatter_json.rb