Search tests: Use on_exit for restoring `persistent_term` state
Otherwise if the assertion failed, the code below which resets the state would never be reached
This commit is contained in:
parent
5a5ff508aa
commit
fc9ebe5073
|
@ -21,6 +21,7 @@ test "it finds something" do
|
|||
test "using plainto_tsquery on postgres < 11" do
|
||||
old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
|
||||
:persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
|
||||
on_exit(fn -> :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version) end)
|
||||
|
||||
user = insert(:user)
|
||||
{:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
|
||||
|
@ -30,8 +31,6 @@ test "using plainto_tsquery on postgres < 11" do
|
|||
assert [result] = Search.search(nil, "wednesday -dudes")
|
||||
|
||||
assert result.id == post.id
|
||||
|
||||
:persistent_term.put({Pleroma.Repo, :postgres_version}, old_version)
|
||||
end
|
||||
|
||||
test "using websearch_to_tsquery" do
|
||||
|
|
|
@ -281,6 +281,7 @@ test "search", %{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})
|
||||
:persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
|
||||
on_exit(fn -> :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version) end)
|
||||
|
||||
capture_log(fn ->
|
||||
{:ok, %{id: activity_id}} =
|
||||
|
@ -298,8 +299,6 @@ test "search fetches remote statuses and prefers them over other results", %{con
|
|||
%{"id" => ^activity_id}
|
||||
] = results["statuses"]
|
||||
end)
|
||||
|
||||
:persistent_term.put({Pleroma.Repo, :postgres_version}, old_version)
|
||||
end
|
||||
|
||||
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
||||
|
|
Loading…
Reference in New Issue