MediaProxyCacheControllerTest: Fix unstable tests.
Cachex order isn't stable, so we can not depend on the order in tests. This adds some sorting to make the tests stable.
This commit is contained in:
parent
2dea4a8c04
commit
871936b3ca
1 changed files with 17 additions and 13 deletions
|
@ -47,30 +47,34 @@ test "shows banned MediaProxy URLs", %{conn: conn} do
|
||||||
assert response["page_size"] == 2
|
assert response["page_size"] == 2
|
||||||
assert response["count"] == 5
|
assert response["count"] == 5
|
||||||
|
|
||||||
assert response["urls"] == [
|
results = response["urls"]
|
||||||
"http://localhost:4001/media/fb1f4d.jpg",
|
|
||||||
"http://localhost:4001/media/a688346.jpg"
|
|
||||||
]
|
|
||||||
|
|
||||||
response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=2")
|
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=2")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert response["urls"] == [
|
|
||||||
"http://localhost:4001/media/gb1f44.jpg",
|
|
||||||
"http://localhost:4001/media/tb13f47.jpg"
|
|
||||||
]
|
|
||||||
|
|
||||||
assert response["page_size"] == 2
|
assert response["page_size"] == 2
|
||||||
assert response["count"] == 5
|
assert response["count"] == 5
|
||||||
|
|
||||||
|
results = results ++ response["urls"]
|
||||||
|
|
||||||
response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=3")
|
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=3")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert response["urls"] == ["http://localhost:4001/media/wb1f46.jpg"]
|
results = results ++ response["urls"]
|
||||||
|
|
||||||
|
assert results |> Enum.sort() ==
|
||||||
|
[
|
||||||
|
"http://localhost:4001/media/wb1f46.jpg",
|
||||||
|
"http://localhost:4001/media/gb1f44.jpg",
|
||||||
|
"http://localhost:4001/media/tb13f47.jpg",
|
||||||
|
"http://localhost:4001/media/fb1f4d.jpg",
|
||||||
|
"http://localhost:4001/media/a688346.jpg"
|
||||||
|
]
|
||||||
|
|> Enum.sort()
|
||||||
end
|
end
|
||||||
|
|
||||||
test "search banned MediaProxy URLs", %{conn: conn} do
|
test "search banned MediaProxy URLs", %{conn: conn} do
|
||||||
|
@ -88,9 +92,9 @@ test "search banned MediaProxy URLs", %{conn: conn} do
|
||||||
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&query=F44")
|
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&query=F44")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert response["urls"] == [
|
assert response["urls"] |> Enum.sort() == [
|
||||||
"http://localhost:4001/media/gb1f44.jpg",
|
"http://localhost:4001/media/ff44b1f4d.jpg",
|
||||||
"http://localhost:4001/media/ff44b1f4d.jpg"
|
"http://localhost:4001/media/gb1f44.jpg"
|
||||||
]
|
]
|
||||||
|
|
||||||
assert response["page_size"] == 2
|
assert response["page_size"] == 2
|
||||||
|
|
Loading…
Reference in a new issue