fix: ensure sync logs are in different minutes for activity feed test
The ActivityFeed groups sync logs by minute, so when creating test data with random timestamps, multiple logs could fall within the same minute and get grouped together, causing the test to fail. Now ensures each sync log is exactly 60 seconds apart (different minutes).
This commit is contained in:
parent
b969a0fe6e
commit
2a5254343e
1 changed files with 7 additions and 3 deletions
|
|
@ -325,7 +325,10 @@ defmodule Towerops.ActivityFeedTest do
|
|||
end
|
||||
|
||||
test "handles different sync statuses", %{organization: organization, integration: integration} do
|
||||
for status <- ["success", "failed", "partial"] do
|
||||
# Create sync logs in different minutes (sync groups by minute)
|
||||
["success", "failed", "partial"]
|
||||
|> Enum.with_index()
|
||||
|> Enum.each(fn {status, idx} ->
|
||||
{:ok, _} =
|
||||
%SyncLog{}
|
||||
|> SyncLog.changeset(%{
|
||||
|
|
@ -333,10 +336,11 @@ defmodule Towerops.ActivityFeedTest do
|
|||
integration_id: integration.id,
|
||||
status: status,
|
||||
records_synced: 10,
|
||||
inserted_at: DateTime.add(~U[2026-03-06 10:00:00Z], :rand.uniform(3600), :second)
|
||||
# Ensure each is in a different minute (60 seconds apart)
|
||||
inserted_at: DateTime.add(~U[2026-03-06 10:00:00Z], idx * 60, :second)
|
||||
})
|
||||
|> Repo.insert()
|
||||
end
|
||||
end)
|
||||
|
||||
activities = ActivityFeed.list_org_activity(organization.id)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue