Remove usage of :persistent_term for Postgres version storage, fix test
This test should not have been passing. The search result's activity id should not be the same id as the local post. capture_log was not being used. Removed.
This commit is contained in:
parent
b822a912ad
commit
357553a64a
@ -322,26 +322,20 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "search fetches remote statuses and prefers them over other results", %{conn: conn} do
|
test "search fetches remote statuses and prefers them over other results", %{conn: conn} do
|
||||||
old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
|
{:ok, %{id: activity_id}} =
|
||||||
:persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
|
CommonAPI.post(insert(:user), %{
|
||||||
on_exit(fn -> :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version) end)
|
status: "check out http://mastodon.example.org/@admin/99541947525187367"
|
||||||
|
})
|
||||||
|
|
||||||
capture_log(fn ->
|
%{"url" => result_url, "id" => result_id} =
|
||||||
{:ok, %{id: activity_id}} =
|
conn
|
||||||
CommonAPI.post(insert(:user), %{
|
|> get("/api/v1/search?q=http://mastodon.example.org/@admin/99541947525187367")
|
||||||
status: "check out http://mastodon.example.org/@admin/99541947525187367"
|
|> json_response_and_validate_schema(200)
|
||||||
})
|
|> Map.get("statuses")
|
||||||
|
|> List.first()
|
||||||
|
|
||||||
results =
|
refute match?(^result_id, activity_id)
|
||||||
conn
|
assert match?(^result_url, "http://mastodon.example.org/@admin/99541947525187367")
|
||||||
|> get("/api/v1/search?q=http://mastodon.example.org/@admin/99541947525187367")
|
|
||||||
|> json_response_and_validate_schema(200)
|
|
||||||
|
|
||||||
assert [
|
|
||||||
%{"url" => "http://mastodon.example.org/@admin/99541947525187367"},
|
|
||||||
%{"id" => ^activity_id}
|
|
||||||
] = results["statuses"]
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
||||||
|
Loading…
Reference in New Issue
Block a user