[Groonga-commit] droonga/fluent-plugin-droonga at daf7cb8 [master] Add a test for gatherer with complex mapping

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Nov 28 16:47:18 JST 2013


YUKI Hiroshi	2013-11-28 16:47:18 +0900 (Thu, 28 Nov 2013)

  New Revision: daf7cb8181b3c71bc033373378fb45a2f593bbef
  https://github.com/droonga/fluent-plugin-droonga/commit/daf7cb8181b3c71bc033373378fb45a2f593bbef

  Message:
    Add a test for gatherer with complex mapping

  Modified files:
    lib/droonga/plugin/collector/basic.rb
    test/unit/plugin/collector/test_basic.rb

  Modified: lib/droonga/plugin/collector/basic.rb (+1 -1)
===================================================================
--- lib/droonga/plugin/collector/basic.rb    2013-11-28 16:43:14 +0900 (d2ed95e)
+++ lib/droonga/plugin/collector/basic.rb    2013-11-28 16:47:18 +0900 (3a9deec)
@@ -33,7 +33,7 @@ module Droonga
           result[element] = apply_output_attributes(result[element], output)
           result[element] = apply_output_format(result[element], output)
         end
-        output = output["source"]
+        output = output["output"]
       end
       emit(result, output)
     end

  Modified: test/unit/plugin/collector/test_basic.rb (+44 -11)
===================================================================
--- test/unit/plugin/collector/test_basic.rb    2013-11-28 16:43:14 +0900 (82365c0)
+++ test/unit/plugin/collector/test_basic.rb    2013-11-28 16:47:18 +0900 (5e736b3)
@@ -28,10 +28,13 @@ class BasicCollectorTest < Test::Unit::TestCase
     teardown_database
   end
 
+  private
+  def create_record(*columns)
+    columns
+  end
+
   class GatherTest < self
-    def test_gather
-      input_name = "input_#{Time.now.to_i}"
-      input_value = "value_#{Time.now.to_i}"
+    def test_simple_mapper
       request = {
         "task" => {
           "values" => nil,
@@ -41,12 +44,47 @@ class BasicCollectorTest < Test::Unit::TestCase
           },
         },
         "id" => nil,
-        "value" => input_value,
-        "name" => input_name,
+        "value" => "result",
+        "name" => "string_name",
+        "descendants" => nil,
+      }
+      @plugin.process("collector_gather", request)
+      assert_equal(["result", "string_name"], @messages.last)
+    end
+
+    def test_complex_mapping
+      request = {
+        "task" => {
+          "values" => nil,
+          "component" => {
+            "body" => nil,
+            "outputs" => nil,
+          },
+        },
+        "id" => nil,
+        "value" => {
+          "count" => 0,
+          "records" => [
+            create_record(0),
+            create_record(1),
+            create_record(2),
+          ],
+        },
+        "name" => {
+          "output" => "search_result",
+        },
         "descendants" => nil,
       }
       @plugin.process("collector_gather", request)
-      assert_equal([input_value, input_name], @messages.last)
+      gathered = {
+        "count" => 0,
+        "records" => [
+          create_record(0),
+          create_record(1),
+          create_record(2),
+        ],
+      }
+      assert_equal([gathered, "search_result"], @messages.last)
     end
   end
 
@@ -380,10 +418,5 @@ class BasicCollectorTest < Test::Unit::TestCase
                    ],
                    @messages.last)
     end
-
-    private
-    def create_record(*columns)
-      columns
-    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index