[Groonga-commit] ranguba/groonga-client at 213adf0 [master] test: add paginate cases

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Fri Feb 3 09:53:18 JST 2017


Kouhei Sutou	2017-02-03 09:53:18 +0900 (Fri, 03 Feb 2017)

  New Revision: 213adf0d419216b2f59e4acc3ea5d6fa61d01f62
  https://github.com/ranguba/groonga-client/commit/213adf0d419216b2f59e4acc3ea5d6fa61d01f62

  Message:
    test: add paginate cases

  Modified files:
    test/request/test-select.rb

  Modified: test/request/test-select.rb (+65 -0)
===================================================================
--- test/request/test-select.rb    2017-02-03 09:53:02 +0900 (8b2a228)
+++ test/request/test-select.rb    2017-02-03 09:53:18 +0900 (f3b3707)
@@ -311,5 +311,70 @@ class TestRequestSelect < Test::Unit::TestCase
                      paginate("9"))
       end
     end
+
+    sub_test_case("paginate") do
+      test("default") do
+        assert_equal({
+                       :table  => "posts",
+                       :offset => "20",
+                       :limit  => "10",
+                     },
+                     paginate(3))
+      end
+
+      test("nil") do
+        assert_equal({
+                       :table  => "posts",
+                       :offset => "20",
+                       :limit  => "10",
+                     },
+                     paginate(3, per_page: nil))
+      end
+
+      test("0") do
+        assert_equal({
+                       :table  => "posts",
+                       :offset => "20",
+                       :limit  => "10",
+                     },
+                     paginate(3, per_page: 0))
+      end
+
+      test("1") do
+        assert_equal({
+                       :table  => "posts",
+                       :offset => "2",
+                       :limit  => "1",
+                     },
+                     paginate(3, per_page: 1))
+      end
+
+      test("positive") do
+        assert_equal({
+                       :table  => "posts",
+                       :offset => "58",
+                       :limit  => "29",
+                     },
+                     paginate(3, per_page: 29))
+      end
+
+      test("negative") do
+        assert_equal({
+                       :table  => "posts",
+                       :offset => "20",
+                       :limit  => "10",
+                     },
+                     paginate(3, per_page: -1))
+      end
+
+      test("string") do
+        assert_equal({
+                       :table  => "posts",
+                       :offset => "58",
+                       :limit  => "29",
+                     },
+                     paginate(3, per_page: "29"))
+      end
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index