YUKI Hiroshi
null+****@clear*****
Thu Nov 21 12:09:00 JST 2013
YUKI Hiroshi 2013-11-21 12:09:00 +0900 (Thu, 21 Nov 2013) New Revision: 5acf046b549c4cf6d2166f8e273fa4edb5da9c40 https://github.com/droonga/fluent-plugin-droonga/commit/5acf046b549c4cf6d2166f8e273fa4edb5da9c40 Message: Test: add tests for "offset" and "limit" parameters of "select" command Modified files: test/unit/plugin/adapter/groonga/test_select.rb Modified: test/unit/plugin/adapter/groonga/test_select.rb (+82 -0) =================================================================== --- test/unit/plugin/adapter/groonga/test_select.rb 2013-11-21 12:04:31 +0900 (080c96c) +++ test/unit/plugin/adapter/groonga/test_select.rb 2013-11-21 12:09:00 +0900 (21ef01f) @@ -145,6 +145,88 @@ class AdapterGroongaSelectTest < Test::Unit::TestCase assert_matchTo(["_key", "content"], "_key || content") end end + + class OffsetTest < self + def assert_offset(expected_offset, offset) + select_request = { + "table" => "EmptyTable", + "output_columns" => "_id", + "offset" => offset, + } + + expected_search_request = { + "queries" => { + "EmptyTable_result" => { + "source" => "EmptyTable", + "output" => { + "elements" => [ + "startTime", + "elapsedTime", + "count", + "attributes", + "records", + ], + "attributes" => ["_id"], + "offset" => expected_offset, + "limit" => 10, + }, + }, + }, + } + assert_equal(expected_search_request, convert(select_request)) + end + + def test_zero + assert_offset(0, "0") + end + + def test_large + assert_offset(100, "100") + end + end + + class LimitTest < self + def assert_limit(expected_limit, limit) + select_request = { + "table" => "EmptyTable", + "output_columns" => "_id", + "limit" => limit, + } + + expected_search_request = { + "queries" => { + "EmptyTable_result" => { + "source" => "EmptyTable", + "output" => { + "elements" => [ + "startTime", + "elapsedTime", + "count", + "attributes", + "records", + ], + "attributes" => ["_id"], + "offset" => 0, + "limit" => expected_limit, + }, + }, + }, + } + assert_equal(expected_search_request, convert(select_request)) + end + + def test_zero + assert_limit(0, "0") + end + + def test_large + assert_offset(100, "100") + end + + def test_negative + assert_offset(-1, "-1") + end + end end class ResponseTest < self -------------- next part -------------- HTML����������������������������...Download