Sha256: d0a4f1438e97d510f44ff6d7b01f7217ea115c38d8d670d5d4dd01f60f0d5e1b

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'fluent/test'
require 'fluent/plugin/out_tdlog'

class TreasureDataLogOutputTest < Test::Unit::TestCase
  def setup
    Fluent::Test.setup
  end

  TMP_DIR = File.dirname(__FILE__) + "/tmp"

  CONFIG = %[
    apikey testkey
    buffer_path #{TMP_DIR}/buffer
  ]

  def create_driver(conf = CONFIG)
    Fluent::Test::BufferedOutputTestDriver.new(Fluent::TreasureDataLogOutput) do
      def start
        super
      end

      def write(chunk)
        chunk.read
      end
    end.configure(conf)
  end

  def test_emit
    d = create_driver

    time = Time.parse("2011-01-02 13:14:15 UTC").to_i
    d.emit({"a"=>1}, time)
    d.emit({"a"=>2}, time)
    d.run
  end

  def test_invalid_name
    d = create_driver
    d.instance.start

    es = Fluent::OneEventStream.new(Time.now.to_i, {})
    chain = Fluent::NullOutputChain.instance
    assert_raise(RuntimeError) do
      d.instance.emit("test.invalid-name", es, chain)
    end
    assert_raise(RuntimeError) do
      d.instance.emit("empty", es, chain)
    end
    assert_raise(RuntimeError) do
      d.instance.emit("", es, chain)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fluent-plugin-td-0.10.3 test/out_tdlog.rb
fluent-plugin-td-0.10.2 test/out_tdlog.rb
fluent-plugin-td-0.10.1 test/out_tdlog.rb