[Groonga-commit] droonga/droonga-engine at 7d1d43e [master] test: Add tests for conversion of "sortby" option

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Apr 28 19:15:46 JST 2014


YUKI Hiroshi	2014-04-28 19:15:46 +0900 (Mon, 28 Apr 2014)

  New Revision: 7d1d43e67c83da21034bb7ab9907341053ab8f9b
  https://github.com/droonga/droonga-engine/commit/7d1d43e67c83da21034bb7ab9907341053ab8f9b

  Message:
    test: Add tests for conversion of "sortby" option

  Modified files:
    test/unit/plugins/groonga/select/test_adapter_input.rb

  Modified: test/unit/plugins/groonga/select/test_adapter_input.rb (+74 -0)
===================================================================
--- test/unit/plugins/groonga/select/test_adapter_input.rb    2014-04-28 19:04:48 +0900 (8dbda1c)
+++ test/unit/plugins/groonga/select/test_adapter_input.rb    2014-04-28 19:15:46 +0900 (5e28943)
@@ -287,6 +287,80 @@ class GroongaSelectAdapterInputTest < Test::Unit::TestCase
     end
   end
 
+  class SortTest < self
+    data(
+      :only_keys => {
+        :input => {
+          :keys => "-_id",
+        },
+        :expected => {
+          :keys => ["-_id"],
+          :offset => 0,
+          :limit => 10,
+        },
+      },
+      :offset => {
+        :input => {
+          :keys => "-_id",
+          :offset => 5,
+        },
+        :expected => {
+          :keys => ["-_id"],
+          :offset => 5,
+          :limit => 10,
+        },
+      },
+      :limit => {
+        :input => {
+          :keys => "-_id",
+          :limit => 5,
+        },
+        :expected => {
+          :keys => ["-_id"],
+          :offset => 0,
+          :limit => 5,
+        },
+      },
+    )
+    def test_sort(data)
+      expected = data[:expected]
+      input = data[:input]
+      select_request = {
+        "table"          => "EmptyTable",
+        "output_columns" => "_id",
+      }
+      select_request["sortby"] = input[:keys]  unless input[:keys].nil?
+      select_request["offset"] = input[:offset]  unless input[:offset].nil?
+      select_request["limit"] = input[:limit]  unless input[:limit].nil?
+
+      expected_search_request = {
+        "queries" => {
+          "EmptyTable_result" => {
+            "source"   => "EmptyTable",
+            "sortBy" => {
+              "keys" => expected[:keys],
+              "offset" => expected[:offset],
+              "limit" => expected[:limit],
+            },
+            "output"   => {
+              "elements"   => [
+                "startTime",
+                "elapsedTime",
+                "count",
+                "attributes",
+                "records",
+              ],
+              "attributes" => ["_id"],
+              "offset" => 0,
+              "limit" => expected[:limit],
+            },
+          },
+        },
+      }
+      assert_equal(expected_search_request, convert(select_request))
+    end
+  end
+
   class DrilldownTest < self
     def base_request
       {
-------------- next part --------------
HTML����������������������������...
Download 



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