Yasuhiro Horimoto
null+****@clear*****
Tue Jan 16 12:08:22 JST 2018
Yasuhiro Horimoto 2018-01-16 12:08:22 +0900 (Tue, 16 Jan 2018) New Revision: e3a5e86a766d43f080c97d04f621df58c9383a18 https://github.com/groonga/fluent-plugin-groonga/commit/e3a5e86a766d43f080c97d04f621df58c9383a18 Merged 638bad8: Merge pull request #26 from komainu8/fluentd-v0.12 Message: test: create test case instead of creating custom driver in test Modified files: test/test_input.rb Modified: test/test_input.rb (+55 -29) =================================================================== --- test/test_input.rb 2018-01-16 11:50:34 +0900 (a97cda4) +++ test/test_input.rb 2018-01-16 12:08:22 +0900 (923ab07) @@ -35,9 +35,9 @@ class GroongaInputTest < Test::Unit::TestCase end private - def create_driver(conf = configuration) + def create_driver driver = Fluent::Test::InputTestDriver.new(Fluent::GroongaInput) - driver.configure(conf) + driver.configure(configuration) driver end @@ -115,33 +115,6 @@ EOC end end - def test_target_command_with_command_name_position_record - @real_response["Content-Type"] = "application/json" - @real_response.body = JSON.generate([[0, 0.0, 0.0], true]) - conf = <<EOC - protocol http - bind #{@host} - port #{@port} - real_host #{@real_host} - real_port #{@real_port} - command_name_position record -EOC - driver = create_driver(conf) - driver.expect_emit("groonga.command", - @now, - { - "name" => "table_create", - "arguments" => { - "name" => "Users", - "flags" => "TABLE_NO_KEY", - } - }) - driver.run do - get("/d/table_create", "name" => "Users", "flags" => "TABLE_NO_KEY") - assert_equal("200", @last_response.code) - end - end - def test_not_target_command @driver.run do get("/d/status") @@ -180,6 +153,59 @@ EOJ end end + sub_test_case("command_name_position") do + sub_test_case("record") do + def configuration + <<-CONFIGURATION + #{super} + command_name_position record + CONFIGURATION + end + + def test_not_load + @real_response["Content-Type"] = "application/json" + @real_response.body = JSON.generate([[0, 0.0, 0.0], true]) + @driver.expect_emit("groonga.command", + @now, + { + "name" => "table_create", + "arguments" => { + "name" => "Users", + "flags" => "TABLE_NO_KEY", + } + }) + @driver.run do + get("/d/table_create", "name" => "Users", "flags" => "TABLE_NO_KEY") + assert_equal("200", @last_response.code) + end + end + + def test_load + @real_response["Content-Type"] = "application/json" + @real_response.body = JSON.generate([[0, 0.0, 0.0], true]) + json = <<-JSON +[ +{"name": "Alice"}, +{"name": "Bob"} +] + JSON + @driver.expect_emit("groonga.command", + @now, + { + "name" => "load", + "arguments" => { + "table" => "Users", + "values" => json, + } + }) + @driver.run do + post("/d/load", json, "table" => "Users") + assert_equal("200", @last_response.code) + end + end + end + end + private def get(path, parameters={}) http = Net::HTTP.new(@host, @port) -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180116/de2e2393/attachment-0003.htm