[Groonga-commit] droonga/fluent-plugin-droonga at cb6d50a [master] Migrate test for multiple sort keys

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 31 17:51:29 JST 2014


YUKI Hiroshi	2014-01-31 17:51:29 +0900 (Fri, 31 Jan 2014)

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

  Message:
    Migrate test for multiple sort keys

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

  Modified: test/unit/plugin/distributor/test_search_planner.rb (+83 -0)
===================================================================
--- test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 17:45:34 +0900 (eafc569)
+++ test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 17:51:29 +0900 (db3dadd)
@@ -859,6 +859,89 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
       end
     end
 
+    class SortByMultipleColumnsTest < self
+      def setup
+        @output = {
+          "elements"   => ["records"],
+          "attributes" => ["_key"],
+          "limit"      => 1,
+        }
+        @sort_by = {
+          "keys" => ["-age", "name", "_key"],
+        }
+        @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" => ["_key", "age", "name"],
+        }
+        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" => 1, "operator" => ">" },
+                             { "column" => 2, "operator" => "<" },
+                             { "column" => 0, "operator" => "<" },
+                           ],
+                           "limit"     => 1,
+                         },
+                       },
+                     },
+                     reduce_message["body"]["users"])
+      end
+
+      def test_gather_records
+        assert_equal({
+                       "elements" => {
+                         "records" => {
+                           "attributes" => ["_key"],
+                           "limit"      => 1,
+                         },
+                       },
+                       "output" => "users",
+                     },
+                     gather_message["body"]["users_reduced"])
+      end
+    end
+
     class SortByOffsetLimitTest < self
       def max_limit
         [@sort_by["limit"], @output["limit"]].max
-------------- next part --------------
HTML����������������������������...
下载 



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