fix: add time buffer to login history boundary test
This commit is contained in:
parent
ffc937821c
commit
a5ba941025
1 changed files with 4 additions and 3 deletions
|
|
@ -173,8 +173,9 @@ defmodule Towerops.Workers.LoginHistoryCleanupWorkerTest do
|
|||
end
|
||||
|
||||
test "handles boundary case for anonymized at exactly 90 days" do
|
||||
# Create an anonymized record at exactly 90 days
|
||||
anon_date = DateTime.add(DateTime.utc_now(), -90, :day)
|
||||
# Create an anonymized record at 90 days minus 1 second (just inside the cutoff)
|
||||
# Adding 1 second buffer to prevent flakiness from time advancement during test execution
|
||||
anon_date = DateTime.utc_now() |> DateTime.add(-90, :day) |> DateTime.add(1, :second)
|
||||
|
||||
boundary_anon =
|
||||
insert_login_attempt(%{
|
||||
|
|
@ -186,7 +187,7 @@ defmodule Towerops.Workers.LoginHistoryCleanupWorkerTest do
|
|||
assert {:ok, %{deleted: _, anonymized_deleted: anon_count}} =
|
||||
LoginHistoryCleanupWorker.perform(%Oban.Job{args: %{}})
|
||||
|
||||
# The query uses `<` not `<=`, so exactly at 90 days should NOT be deleted
|
||||
# The query uses `<` not `<=`, so at 90 days - 1 second should NOT be deleted
|
||||
assert anon_count == 0
|
||||
assert Repo.get(LoginAttempt, boundary_anon.id)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue