Sha256: 96ecfde13ba3fd7be6713e2424e5c06e7fa42bca545f9b322391c65033d70f9e
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
require 'test_helper' require 'fluent/plugin/out_tditem' class TreasureDataItemOutputTest < Test::Unit::TestCase def setup Fluent::Test.setup end DEFAULT_CONFIG = %[ database test table table ] def create_driver(conf = DEFAULT_CONFIG) config = %[ apikey testkey buffer_type memory ] + conf Fluent::Test::BufferedOutputTestDriver.new(Fluent::TreasureDataItemOutput) do def write(chunk) # TestDriver doesn't call acutual Output#emit so set key to get database and table in this place. chunk.instance_variable_set(:@key, @key) super(chunk) end end.configure(config) end def test_configure d = create_driver assert_equal('testkey', d.instance.apikey) assert_equal('test', d.instance.database) assert_equal('table', d.instance.table) assert_equal(true, d.instance.use_ssl) assert_equal('memory', d.instance.buffer_type) assert_equal(300, d.instance.flush_interval) end def test_configure_with_invalid_database assert_raise(Fluent::ConfigError) { create_driver(%[ database a table table ]) } end def test_configure_with_invalid_table assert_raise(Fluent::ConfigError) { create_driver(%[ database test table 1 ]) } end def test_emit d = create_driver time, records = stub_seed_values stub_td_import_request(stub_request_body(records), d.instance.database, d.instance.table) records.each { |record| d.emit(record, time) } d.run assert_equal('TD1 testkey', @auth_header) end def test_emit d = create_driver(DEFAULT_CONFIG + "endpoint foo.bar.baz") opts = {:endpoint => 'foo.bar.baz'} time, records = stub_seed_values stub_td_import_request(stub_request_body(records), d.instance.database, d.instance.table, opts) records.each { |record| d.emit(record, time) } d.run assert_equal('TD1 testkey', @auth_header) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-td-0.10.20 | test/plugin/test_out_tditem.rb |
fluent-plugin-td-0.10.19 | test/plugin/test_out_tditem.rb |