Sha256: 2306f4adb6f92f0dd095c370aa261b91dc941dd700429e590f1fd5565ee143ce

Contents?: true

Size: 961 Bytes

Versions: 11

Compression:

Stored size: 961 Bytes

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_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

11 entries across 11 versions & 1 rubygems

Version Path
fluentd-0.14.11-x64-mingw32 test/plugin/test_formatter_json.rb
fluentd-0.14.11-x86-mingw32 test/plugin/test_formatter_json.rb
fluentd-0.14.11 test/plugin/test_formatter_json.rb
fluentd-0.14.10-x64-mingw32 test/plugin/test_formatter_json.rb
fluentd-0.14.10-x86-mingw32 test/plugin/test_formatter_json.rb
fluentd-0.14.10 test/plugin/test_formatter_json.rb
fluentd-0.14.9 test/plugin/test_formatter_json.rb
fluentd-0.14.8 test/plugin/test_formatter_json.rb
fluentd-0.14.7-x64-mingw32 test/plugin/test_formatter_json.rb
fluentd-0.14.7-x86-mingw32 test/plugin/test_formatter_json.rb
fluentd-0.14.7 test/plugin/test_formatter_json.rb