[Groonga-commit] droonga/fluent-plugin-droonga at e28d993 [master] Migrate test for sortBy with hash style attributes

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 31 18:03:26 JST 2014


YUKI Hiroshi	2014-01-31 18:03:26 +0900 (Fri, 31 Jan 2014)

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

  Message:
    Migrate test for sortBy with hash style attributes

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

  Modified: test/unit/plugin/distributor/test_search_planner.rb (+88 -54)
===================================================================
--- test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 17:57:11 +0900 (a3896b1)
+++ test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 18:03:26 +0900 (55884e7)
@@ -859,6 +859,94 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
       end
     end
 
+    class ComplexSortWithHashAttributesTest < self
+      def setup
+        @output = {
+          "elements"   => ["records"],
+          "attributes" => {
+            "id"   => "_key",
+            "name" => { "source" => "name" },
+          },
+          "limit"      => 1,
+        }
+        @sort_by = {
+          "keys" => ["hidden"],
+        }
+        @request = {
+          "type" => "search",
+          "dataset" => "Droonga",
+          "body" => {
+            "queries" => {
+              "users" => {
+                "source" => "User",
+                "sortBy" => @sort_by,
+                "output" => @output,
+              },
+            },
+          },
+        }
+      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
+        changed_sort_by_parameters = {
+          "offset" => 0,
+          "limit"  => 1,
+        }
+        changed_output_parameters = {
+          "attributes" => [
+            { "label" => "id",   "source" => "_key" },
+            { "label" => "name", "source" => "name" },
+            "hidden",
+          ],
+        }
+        assert_equal({
+                       "queries" => {
+                         "users" => {
+                           "source" => "User",
+                           "sortBy" => @sort_by.merge(changed_sort_by_parameters),
+                           "output" => @output.merge(changed_output_parameters),
+                         },
+                       },
+                     },
+                     broadcast_message["body"])
+      end
+
+      def test_reduce_body
+        assert_equal({
+                       "users_reduced" => {
+                         "records" => {
+                           "type"      => "sort",
+                           "operators" => [
+                             { "column" => 2, "operator" => "<" },
+                           ],
+                           "limit"     => 1,
+                         },
+                       },
+                     },
+                     reduce_message["body"]["users"])
+      end
+
+      def test_gather_records
+        assert_equal({
+                       "elements" => {
+                         "records" => {
+                           "attributes" => ["id", "name"],
+                           "limit"      => 1,
+                         },
+                       },
+                       "output" => "users",
+                     },
+                     gather_message["body"]["users_reduced"])
+      end
+    end
+
     class ComplexSortByMultipleColumnsTest < self
       def setup
         @output = {
@@ -1307,60 +1395,6 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
 
 =begin
   class SingleQueryTest < self
-    def test_hash_attributes
-      request = {
-        "type" => "search",
-        "dataset" => "Droonga",
-        "body" => {
-          "queries" => {
-            "have_records" => {
-              "source" => "User",
-              "sortBy" => {
-                "keys" => ["-public_age", "public_name"],
-                "limit" => -1,
-              },
-              "output" => {
-                "format" => "complex",
-                "elements" => ["records"],
-                "attributes" => {
-                  "id" => "_key",
-                  "name" => { "source" => "name" },
-                  "age" => { "source" => "age" },
-                },
-                "limit" => -1,
-              },
-            },
-          },
-        },
-      }
-
-      expected_plan = []
-      expected_plan << reducer(request, {
-        "records" => {
-          "type" => "sort",
-          "operators" => [
-            { "column" => 3, "operator" => ">" },
-            { "column" => 4, "operator" => "<" },
-          ],
-          "limit" => -1,
-        },
-      })
-      expected_plan << gatherer(request, :elements => {
-                                           "records" => records_mapper(
-                                             :offset => 0,
-                                             :limit => -1,
-                                             :format => "complex",
-                                             :attributes => ["id", "name", "age"],
-                                           ),
-                                         })
-      expected_plan << searcher(request, :sort_offset => 0,
-                                         :sort_limit => -1,
-                                         :output_offset => 0,
-                                         :output_limit => -1,
-                                         :extra_attributes => ["public_age", "public_name"])
-      assert_equal(expected_plan, plan(request))
-    end
-
     def test_groupBy
       request = {
         "type" => "search",
-------------- next part --------------
HTML����������������������������...
Download 



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