Kouhei Sutou
null+****@clear*****
Thu Mar 28 16:25:29 JST 2013
Kouhei Sutou 2013-03-28 16:25:29 +0900 (Thu, 28 Mar 2013) New Revision: e57c17431d9eccdb3105041c33a7522cc79b921d https://github.com/groonga/fluent-plugin-droonga/commit/e57c17431d9eccdb3105041c33a7522cc79b921d Message: Test that output passes a request to worker Modified files: test/test_output.rb Modified: test/test_output.rb (+10 -4) =================================================================== --- test/test_output.rb 2013-03-28 16:17:36 +0900 (1c89137) +++ test/test_output.rb 2013-03-28 16:25:29 +0900 (d0f72a7) @@ -17,11 +17,14 @@ require "fluent/plugin/out_droonga" module OutputStub class Worker + attr_reader :processed_record def initialize(response) @response = response + @processed_record = nil end def process_message(record) + @processed_record = record @response end @@ -30,6 +33,7 @@ module OutputStub end class Output < Fluent::DroongaOutput + attr_reader :worker def initialize(response) @response = response super() @@ -47,19 +51,21 @@ class OutputTest < Test::Unit::TestCase Fluent::Test.setup end - def test_emit + def test_exec response = {} driver = create_driver("droonga.message", response) + request = {"hello" => "world"} time = Time.parse("2012-10-26T08:45:42Z").to_i driver.run do - driver.emit({"replyTo" => "127.0.0.1:2929/droonga.message"}, time) + driver.emit(request, time) end + assert_equal(request, @output.worker.processed_record) end private def create_driver(tag, response) - output = OutputStub::Output.new(response) - driver = Fluent::Test::OutputTestDriver.new(output, tag) + @output = OutputStub::Output.new(response) + driver = Fluent::Test::OutputTestDriver.new(@output, tag) driver.configure(configuration) driver end -------------- next part -------------- HTML����������������������������...Download