[Groonga-commit] droonga/fluent-plugin-droonga at 2faa30f [master] test: extract tests for "'elements": ["count"]' case

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jan 30 15:50:08 JST 2014


Kouhei Sutou	2014-01-30 15:50:08 +0900 (Thu, 30 Jan 2014)

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

  Message:
    test: extract tests for "'elements": ["count"]' case

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

  Modified: test/unit/plugin/distributor/test_search_planner.rb (+63 -33)
===================================================================
--- test/unit/plugin/distributor/test_search_planner.rb    2014-01-30 15:41:46 +0900 (cdfbd27)
+++ test/unit/plugin/distributor/test_search_planner.rb    2014-01-30 15:50:08 +0900 (d6c9e06)
@@ -180,6 +180,69 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
       end
     end
 
+    class ElementsTest < self
+      class CountTest < self
+        def setup
+          @request = {
+            "type" => "search",
+            "dataset" => "Droonga",
+            "body" => {
+              "queries" => {
+                "users" => {
+                  "source" => "User",
+                  "output" => {
+                    "elements" => ["count"],
+                  },
+                },
+              },
+            },
+          }
+        end
+
+        def test_dependencies
+          reduce_inputs = ["errors", "users"]
+          gather_inputs = ["errors_reduced", "users_reduced"]
+          assert_equal(expected_dependencies(reduce_inputs, gather_inputs),
+                       dependencies)
+        end
+
+        def test_broadcast_body
+          assert_equal({
+                         "queries" => {
+                           "users" => {
+                             "output" => {
+                               "elements" => ["count"],
+                               "format"   => "simple", # TODO: remove me
+                               "limit"    => 0,        # TODO: remove me
+                             },
+                             "source" => "User",
+                           },
+                         },
+                       },
+                       broadcast_message["body"])
+        end
+
+        def test_reduce_body
+          assert_equal({
+                         "users_reduced" => {
+                           "count" => {
+                             "type" => "sum",
+                           },
+                         },
+                       },
+                       reduce_message["body"]["users"])
+        end
+
+        def test_gather_body
+          assert_equal({
+                         "elements" => {}, # TODO: remove me
+                         "output" => "users",
+                       },
+                       gather_message["body"]["users_reduced"])
+        end
+      end
+    end
+
     class FormatTest < self
       def setup
         @output = {
@@ -246,39 +309,6 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
   end
 
   class SingleQueryTest < self
-    def test_no_records_element
-      request = {
-        "type" => "search",
-        "dataset" => "Droonga",
-        "body" => {
-          "queries" => {
-            "no_records" => {
-              "source" => "User",
-              "sortBy" => {
-                "keys" => ["name"],
-                "offset" => 0,
-                "limit" => 1,
-              },
-              "output" => {
-                "elements" => ["count"],
-              },
-            },
-          },
-        },
-      }
-
-      expected_plan = []
-      expected_plan << reducer(request, {
-        "count" => {
-          "type" => "sum",
-        },
-      })
-      expected_plan << gatherer(request)
-      expected_plan << searcher(request, :sort_limit => 1,
-                                         :output_limit => 0)
-      assert_equal(expected_plan, plan(request))
-    end
-
     def test_no_output_limit
       request = {
         "type" => "search",
-------------- next part --------------
HTML����������������������������...
Download 



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