[Groonga-commit] droonga/fluent-plugin-droonga at 788d6e1 [master] test: split no "output" case test

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jan 30 15:31:37 JST 2014


Kouhei Sutou	2014-01-30 15:31:37 +0900 (Thu, 30 Jan 2014)

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

  Message:
    test: split no "output" case test

  Modified files:
    test/unit/plugin/distributor/test_search_planner.rb

  Modified: test/unit/plugin/distributor/test_search_planner.rb (+74 -19)
===================================================================
--- test/unit/plugin/distributor/test_search_planner.rb    2014-01-30 15:21:20 +0900 (5d1aff6)
+++ test/unit/plugin/distributor/test_search_planner.rb    2014-01-30 15:31:37 +0900 (8e20d72)
@@ -32,6 +32,12 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
     end
   end
 
+  def reduce_message(messages)
+    messages.find do |message|
+      message["type"] == "search_reduce"
+    end
+  end
+
   def gather_message(messages)
     messages.find do |message|
       message["type"] == "search_gather"
@@ -114,31 +120,80 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
     end
   end
 
-  class SingleQueryTest < self
-    def test_no_output
-      request = {
-        "type" => "search",
-        "dataset" => "Droonga",
-        "body" => {
-          "queries" => {
-            "no_output" => {
-              "source" => "User",
-              "sortBy" => {
-                "keys" => ["name"],
-                "offset" => 0,
-                "limit" => 1,
+  class OutputTest < self
+    class NothingTest < self
+      def setup
+        @request = {
+          "type" => "search",
+          "dataset" => "Droonga",
+          "body" => {
+            "queries" => {
+              "no_output" => {
+                "source" => "User",
               },
             },
           },
-        },
-      }
+        }
+      end
 
-      expected_plan = []
-      expected_plan << gatherer(request, :no_output => true)
-      expected_plan << searcher(request, :no_output => true)
-      assert_equal(expected_plan, plan(request))
+      def test_dependencies
+        search_reduce_inputs = ["errors"]
+        search_gather_inputs = ["errors_reduced"]
+        assert_equal([
+                       {
+                         "type"    => "search_reduce",
+                         "inputs"  => search_reduce_inputs,
+                         "outputs" => search_gather_inputs,
+                       },
+                       {
+                         "type"    => "search_gather",
+                         "inputs"  => search_gather_inputs,
+                         "outputs" => nil,
+                       },
+                       {
+                         "type"    => "broadcast",
+                         "inputs"  => nil,
+                         "outputs" => search_reduce_inputs,
+                       },
+                     ],
+                     dependencies(messages))
+      end
+
+      def test_broadcast_body
+        assert_equal({
+                       "queries" => {
+                         "no_output" => {
+                           "source" => "User",
+                         },
+                       },
+                     },
+                     broadcast_message(messages)["body"])
+      end
+
+      def test_reduce_body
+        assert_equal({
+                       "errors" => {
+                         "errors_reduced" => {
+                           "type"  => "sum",
+                           "limit" => -1,
+                         },
+                       },
+                     },
+                     reduce_message(messages)["body"])
+      end
+
+      def test_gather_body
+        assert_equal({
+                       "errors_reduced" => {
+                         "output" => "errors",
+                       },
+                     },
+                     gather_message(messages)["body"])
+      end
     end
+  end
 
+  class SingleQueryTest < self
     def test_no_records_element
       request = {
         "type" => "search",
-------------- next part --------------
HTML����������������������������...
Download 



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