Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/elixir/test/config/search.elixir
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"facet counts, empty",
"facet ranges, empty",
"facet ranges, non-empty",
"group search",
"timeouts do not expose internal state"
],
"BasicTextTest": [
Expand Down
22 changes: 22 additions & 0 deletions test/elixir/test/search_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,28 @@ defmodule SearchTest do
assert ranges == %{"price" => %{}}
end

@tag :with_db
test "group search", context do
db_name = context[:db_name]
create_search_docs(db_name)
create_ddoc(db_name)

url = "/#{db_name}/_design/inventory/_search/fruits"
ranges = %{"price" => %{}}
resp = Couch.get(url, query: %{q: "*:*", group_field: "state"})
assert_on_status(resp, 200, "Fail to do search.")

%{:body => %{"groups" => groups}} = resp
assert length(groups) == 3
Enum.each(groups, fn g ->
case g["by"] do
"new" -> assert g["total_rows"] == 2
"old" -> assert g["total_rows"] == 1
"unknown" -> assert g["total_rows"] == 1
end
end)
end

@tag :with_db
test "timeouts do not expose internal state", context do
db_name = context[:db_name]
Expand Down