test/plugin/test_out_sql.rb in fluent-plugin-sql-0.6.1 vs test/plugin/test_out_sql.rb in fluent-plugin-sql-1.0.0.rc1

- old
+ new

@@ -1,6 +1,7 @@ require "helper" +require "fluent/test/driver/output" class SqlOutputTest < Test::Unit::TestCase def setup Fluent::Test.setup end @@ -24,11 +25,11 @@ column_mapping timestamp:created_at,host:host,ident:ident,pid:pid,message:message </table> ] def create_driver(conf = CONFIG) - Fluent::Test::BufferedOutputTestDriver.new(Fluent::SQLOutput).configure(conf) + Fluent::Test::Driver::Output.new(Fluent::Plugin::SQLOutput).configure(conf) end def test_configure d = create_driver expected = { @@ -59,15 +60,15 @@ def test_emit d = create_driver time = Time.parse("2011-01-02 13:14:15 UTC").to_i - d.emit({"message" => "message1"}, time) - d.emit({"message" => "message2"}, time) + d.run(default_tag: 'test') do + d.feed(time, {"message" => "message1"}) + d.feed(time, {"message" => "message2"}) + end - d.run - default_table = d.instance.instance_variable_get(:@default_table) model = default_table.instance_variable_get(:@model) assert_equal(2, model.all.count) messages = model.pluck(:message).sort assert_equal(["message1", "message2"], messages) @@ -76,14 +77,14 @@ class Fallback < self def test_simple d = create_driver time = Time.parse("2011-01-02 13:14:15 UTC").to_i - d.emit({"message" => "message1"}, time) - d.emit({"message" => "message2"}, time) + d.run(default_tag: 'test') do + d.feed(time, {"message" => "message1"}) + d.feed(time, {"message" => "message2"}) - d.run do default_table = d.instance.instance_variable_get(:@default_table) model = default_table.instance_variable_get(:@model) mock(model).import(anything).at_least(1) do raise ActiveRecord::Import::MissingColumnError.new("dummy_table", "dummy_column") end @@ -93,13 +94,13 @@ def test_limit d = create_driver time = Time.parse("2011-01-02 13:14:15 UTC").to_i - d.emit({"message" => "message1"}, time) - d.emit({"message" => "message2"}, time) + d.run(default_tag: 'test') do + d.feed(time, {"message" => "message1"}) + d.feed(time, {"message" => "message2"}) - d.run do default_table = d.instance.instance_variable_get(:@default_table) model = default_table.instance_variable_get(:@model) mock(model).import([anything, anything]).once do raise ActiveRecord::Import::MissingColumnError.new("dummy_table", "dummy_column") end