Skip to content

Commit

Permalink
Fix async flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Nov 3, 2024
1 parent e0e0c84 commit 5351d80
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/mindwendel/accounts_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,16 @@ defmodule Mindwendel.AccountsTest do
)

# we want to make sure that the database is not handling this with a foreign key restraint, but rather that it's handled in the app:
{_result, log} =
with_log(fn ->
log =
capture_log(fn ->
Accounts.delete_inactive_users()
end)

assert Repo.exists?(from u in User, where: u.id == ^old_user.id)
assert log == ""
# we don't expect actual logs but due to async running other tests may emit logs at
# the same time and so we want to make sure here that no delete logs around the user
# are emitted
refute log =~ ~r/delet.*#{old_user.id}/i
end
end
end

0 comments on commit 5351d80

Please sign in to comment.