test/plugin/test_out_tdlog.rb in fluent-plugin-td-0.10.28 vs test/plugin/test_out_tdlog.rb in fluent-plugin-td-0.10.29

- old
+ new

@@ -1,15 +1,10 @@ require 'fluent/test' require 'fluent/plugin/out_tdlog' require 'test_helper.rb' class TreasureDataLogOutputTest < Test::Unit::TestCase - # BufferedOutputTestDriver uses module_eval, not inheritance. - # This DummyOutput is for testing actual write method with webmock - class TreasureDataLogDummyOutput < Fluent::TreasureDataLogOutput - end - def setup Fluent::Test.setup end TMP_DIR = File.dirname(__FILE__) + "/tmp" @@ -23,13 +18,16 @@ config = %[ apikey testkey buffer_path #{TMP_DIR}/buffer ] + conf - Fluent::Test::BufferedOutputTestDriver.new(TreasureDataLogDummyOutput) do + Fluent::Test::BufferedOutputTestDriver.new(Fluent::TreasureDataLogOutput) do def write(chunk) chunk.instance_variable_set(:@key, @key) + def chunk.key + @key + end super(chunk) end end.configure(config) end @@ -49,11 +47,11 @@ stub_td_table_create_request(database, table) stub_td_import_request(stub_request_body(records, time), database, table) assert_rr { # mock(d.instance).gzip_by_writer(is_a(Fluent::BufferChunk), is_a(Tempfile)) causes empty request body so using dont_allow instead to check calling method # We need actual gzipped content to verify compressed body is correct or not. - dont_allow(d.instance).gzip_by_command(is_a(Fluent::BufferChunk), is_a(Tempfile)) + dont_allow(d.instance).gzip_by_command(anything, is_a(Tempfile)) records.each { |record| d.emit(record, time) } d.run @@ -68,10 +66,10 @@ database, table = d.instance.instance_variable_get(:@key).split(".", 2) stub_td_table_create_request(database, table) stub_td_import_request(stub_request_body(records, time), database, table) assert_rr { # same as test_emit - dont_allow(d.instance).gzip_by_writer(is_a(Fluent::BufferChunk), is_a(Tempfile)) + dont_allow(d.instance).gzip_by_writer(anything, is_a(Tempfile)) records.each { |record| d.emit(record, time) } d.run