Navigation Menu

Skip to content

Commit

Permalink
response-comparer: support sort_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 13, 2018
1 parent 9b8e890 commit c7709d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/groonga-query-log/response-comparer.rb
Expand Up @@ -95,7 +95,7 @@ def random_sort?
end

def score_sort?
sort_items = (@command.sortby || "").split(/\s*,\s*/)
sort_items = @command.sort_keys
normalized_sort_items = sort_items.collect do |item|
item.gsub(/\A[+-]/, "")
end
Expand Down
25 changes: 22 additions & 3 deletions test/test-response-comparer.rb
Expand Up @@ -115,14 +115,33 @@ def random_score?(scorer)
end
end

class SortbyTest < self
class SortKeysTest < self
class DetectScoreSortTest < self
private
def score_sort?(sortby)
@command["sortby"] = sortby
def score_sort?(sort_keys)
@command[:sort_keys] = sort_keys
comparer([[[0], []]], [[[0], []]]).send(:score_sort?)
end

class ParameterNameTest < self
def score_sort?(parameter_name)
@command[parameter_name] = "_score"
comparer([[[0], []]], [[[0], []]]).send(:score_sort?)
end

def test_sortby
assert do
score_sort?(:sortby)
end
end

def test_sort_keys
assert do
score_sort?(:sort_keys)
end
end
end

class NoScoreTest < self
def test_nil
assert_false(score_sort?(nil))
Expand Down

0 comments on commit c7709d5

Please sign in to comment.