Delete test/plausible/pagination_test.exs with huggingface_hub
Browse files
test/plausible/pagination_test.exs
DELETED
|
@@ -1,64 +0,0 @@
|
|
| 1 |
-
defmodule Plausible.PaginationTest do
|
| 2 |
-
use Plausible.DataCase, async: true
|
| 3 |
-
|
| 4 |
-
alias Plausible.Pagination
|
| 5 |
-
import Ecto.Query
|
| 6 |
-
|
| 7 |
-
setup do
|
| 8 |
-
sites = insert_list(12, :site)
|
| 9 |
-
{:ok, %{sites: sites, query: from(s in Plausible.Site, order_by: [desc: :id])}}
|
| 10 |
-
end
|
| 11 |
-
|
| 12 |
-
test "default page size", %{query: q} do
|
| 13 |
-
pagination = Pagination.paginate(q, %{}, cursor_fields: [id: :desc])
|
| 14 |
-
|
| 15 |
-
assert Enum.count(pagination.entries) == 10
|
| 16 |
-
assert pagination.metadata.after
|
| 17 |
-
assert pagination.metadata.limit == 10
|
| 18 |
-
refute pagination.metadata.before
|
| 19 |
-
end
|
| 20 |
-
|
| 21 |
-
test "limit can be overridden", %{query: q} do
|
| 22 |
-
pagination = Pagination.paginate(q, %{"limit" => 3}, cursor_fields: [id: :desc])
|
| 23 |
-
|
| 24 |
-
assert Enum.count(pagination.entries) == 3
|
| 25 |
-
assert pagination.metadata.limit == 3
|
| 26 |
-
end
|
| 27 |
-
|
| 28 |
-
test "limit exceeds all entries count", %{query: q, sites: sites} do
|
| 29 |
-
pagination = Pagination.paginate(q, %{"limit" => 100}, cursor_fields: [id: :desc])
|
| 30 |
-
|
| 31 |
-
assert Enum.count(pagination.entries) == Enum.count(sites)
|
| 32 |
-
end
|
| 33 |
-
|
| 34 |
-
test "user provided limit exceeds maximum limit", %{query: q} do
|
| 35 |
-
pagination = Pagination.paginate(q, %{"limit" => 200}, cursor_fields: [id: :desc])
|
| 36 |
-
assert pagination.metadata.limit == 10
|
| 37 |
-
end
|
| 38 |
-
|
| 39 |
-
test "limit supplied as a string", %{query: q} do
|
| 40 |
-
pagination = Pagination.paginate(q, %{"limit" => "3"}, cursor_fields: [id: :desc])
|
| 41 |
-
|
| 42 |
-
assert Enum.count(pagination.entries) == 3
|
| 43 |
-
assert pagination.metadata.limit == 3
|
| 44 |
-
end
|
| 45 |
-
|
| 46 |
-
test "next/prev page", %{query: q} do
|
| 47 |
-
page1 = Pagination.paginate(q, %{"limit" => 3}, cursor_fields: [id: :desc])
|
| 48 |
-
|
| 49 |
-
page_after = page1.metadata.after
|
| 50 |
-
|
| 51 |
-
page2 =
|
| 52 |
-
Pagination.paginate(q, %{"limit" => 3, "after" => page_after}, cursor_fields: [id: :desc])
|
| 53 |
-
|
| 54 |
-
assert page1.entries != page2.entries
|
| 55 |
-
assert Enum.count(page1.entries) == Enum.count(page2.entries)
|
| 56 |
-
|
| 57 |
-
page_before = page2.metadata.before
|
| 58 |
-
|
| 59 |
-
assert ^page1 =
|
| 60 |
-
Pagination.paginate(q, %{"limit" => 3, "before" => page_before},
|
| 61 |
-
cursor_fields: [id: :desc]
|
| 62 |
-
)
|
| 63 |
-
end
|
| 64 |
-
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|