diff options
| author | ILYA Khlopotov <iilyak@apache.org> | 2020-05-20 12:50:46 -0700 |
|---|---|---|
| committer | ILYA Khlopotov <iilyak@apache.org> | 2020-05-20 13:02:36 -0700 |
| commit | fad38281474813f8479c7fb71862555b7f381755 (patch) | |
| tree | b5253f807e259fb5df27cc6e4404e3ef6def4b7d /src/chttpd/test/exunit | |
| parent | 6f2417e1af712b3720cf6c07713d7751cbc9fbef (diff) | |
| download | couchdb-fad38281474813f8479c7fb71862555b7f381755.tar.gz | |
Fix handling of limit query parameter
Diffstat (limited to 'src/chttpd/test/exunit')
| -rw-r--r-- | src/chttpd/test/exunit/pagination_test.exs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/chttpd/test/exunit/pagination_test.exs b/src/chttpd/test/exunit/pagination_test.exs index fcb8f9add..140a5dc88 100644 --- a/src/chttpd/test/exunit/pagination_test.exs +++ b/src/chttpd/test/exunit/pagination_test.exs @@ -384,6 +384,55 @@ defmodule Couch.Test.Pagination do assert resp.status_code == 200, "got error #{inspect(resp.body)}" end + test ": _all_docs?page_size=4 should respect limit", ctx do + %{session: session, db_name: db_name} = ctx + + resp = + Couch.Session.get(session, "/#{db_name}/_all_docs", + query: %{page_size: ctx.page_size, limit: ctx.page_size - 2} + ) + + assert resp.status_code == 200, "got error #{inspect(resp.body)}" + assert length(resp.body["rows"]) == ctx.page_size - 2 + assert not Map.has_key?(resp.body, "next") + + resp = + Couch.Session.get(session, "/#{db_name}/_all_docs", + query: %{page_size: ctx.page_size, limit: ctx.page_size - 1} + ) + + assert resp.status_code == 200, "got error #{inspect(resp.body)}" + assert length(resp.body["rows"]) == ctx.page_size - 1 + assert not Map.has_key?(resp.body, "next") + + resp = + Couch.Session.get(session, "/#{db_name}/_all_docs", + query: %{page_size: ctx.page_size, limit: ctx.page_size} + ) + + assert resp.status_code == 200, "got error #{inspect(resp.body)}" + assert length(resp.body["rows"]) == ctx.page_size + assert not Map.has_key?(resp.body, "next") + + resp = + Couch.Session.get(session, "/#{db_name}/_all_docs", + query: %{page_size: ctx.page_size, limit: ctx.page_size + 1} + ) + + assert resp.status_code == 200, "got error #{inspect(resp.body)}" + assert length(resp.body["rows"]) == ctx.page_size + assert Map.has_key?(resp.body, "next") + + resp = + Couch.Session.get(session, "/#{db_name}/_all_docs", + query: %{page_size: ctx.page_size, limit: ctx.page_size + 2} + ) + + assert resp.status_code == 200, "got error #{inspect(resp.body)}" + assert length(resp.body["rows"]) == ctx.page_size + assert Map.has_key?(resp.body, "next") + end + test ": _all_docs/queries should limit number of queries", ctx do queries = %{ queries: [%{}, %{}, %{}, %{}, %{}] |
