Navigation Menu

Skip to content

Commit

Permalink
test: Add tests for conversion of "sortby" option
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 28, 2014
1 parent d0ff25e commit 7d1d43e
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions test/unit/plugins/groonga/select/test_adapter_input.rb
Expand Up @@ -287,6 +287,80 @@ def test_default
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
{
Expand Down

0 comments on commit 7d1d43e

Please sign in to comment.