[Groonga-commit] droonga/fluent-plugin-droonga at 6728db4 [master] Add test for searchBy with an array of complex attributes

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 31 18:52:37 JST 2014


YUKI Hiroshi	2014-01-31 18:52:37 +0900 (Fri, 31 Jan 2014)

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

  Message:
    Add test for searchBy with an array of complex attributes

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

  Modified: test/unit/plugin/distributor/test_search_planner.rb (+87 -0)
===================================================================
--- test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 18:52:21 +0900 (0bcec6f)
+++ test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 18:52:37 +0900 (b96f0d8)
@@ -949,6 +949,93 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
       end
     end
 
+    class WithComplexAttributesArrayTest < self
+      def setup
+        @output = {
+          "elements"   => ["records"],
+          "attributes" => [
+            { "label" => "id",        "source" => "_key" },
+            { "label" => "real_name", "source" => "name" },
+          ],
+          "limit"      => 1,
+        }
+        @sort_by = {
+          "keys" => ["name"],
+        }
+        @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" => "real_name", "source" => "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" => "<" },
+                           ],
+                           "limit"     => 1,
+                         },
+                       },
+                     },
+                     reduce_message["body"]["users"])
+      end
+
+      def test_gather_records
+        assert_equal({
+                       "elements" => {
+                         "records" => {
+                           "attributes" => ["id", "real_name"],
+                           "limit"      => 1,
+                         },
+                       },
+                       "output" => "users",
+                     },
+                     gather_message["body"]["users_reduced"])
+      end
+    end
+
     class MultipleColumnsTest < self
       def setup
         @output = {
-------------- next part --------------
HTML����������������������������...
Download 



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