fix: add time buffer to backup timeout boundary test
This commit is contained in:
parent
a5ba941025
commit
7dcd2850da
1 changed files with 5 additions and 3 deletions
|
|
@ -119,19 +119,21 @@ defmodule Towerops.Workers.BackupTimeoutWorkerTest do
|
|||
test "handles boundary case at exactly 5 minutes" do
|
||||
device = insert_device()
|
||||
|
||||
# Create a request at exactly 5 minutes (300 seconds) ago
|
||||
# Create a request at 5 minutes minus 1 second (just inside the cutoff)
|
||||
# Adding 1 second buffer to prevent flakiness from time advancement during test execution
|
||||
{:ok, boundary_request} = BackupRequests.create_request(device.id, "job_boundary")
|
||||
|
||||
boundary_request
|
||||
|> Ecto.Changeset.change(
|
||||
requested_at: DateTime.utc_now() |> DateTime.add(-300, :second) |> DateTime.truncate(:second)
|
||||
requested_at:
|
||||
DateTime.utc_now() |> DateTime.add(-300, :second) |> DateTime.add(1, :second) |> DateTime.truncate(:second)
|
||||
)
|
||||
|> Repo.update!()
|
||||
|
||||
# Execute the worker
|
||||
assert :ok = BackupTimeoutWorker.perform(%Oban.Job{args: %{}})
|
||||
|
||||
# The cutoff uses `< cutoff`, so exactly 5 minutes should NOT timeout
|
||||
# The cutoff uses `< cutoff`, so at 5 minutes - 1 second should NOT timeout
|
||||
updated = Repo.reload(boundary_request)
|
||||
assert updated.status == "pending"
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue