Skip to content

Commit 3903508

Browse files
committed
set last connected at for other agents
1 parent 2667160 commit 3903508

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

coderd/database/dbpurge/dbpurge_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,17 @@ func TestPurge(t *testing.T) {
5353

5454
agentIDs, _ := seed(ctx, t, db, opts)
5555

56-
// For half of the agents, set their last connected time to one week ago plus some non-zero interval
57-
for i := 0; i < opts.NumAgents/2; i++ {
58-
randOldTime := weekAgo.AddDate(0, 0, -randintn(7))
59-
setAgentLastConnectedAt(ctx, t, db, agentIDs[i], randOldTime)
56+
// Set last connectd time for agents.
57+
// For half of the agents, set their last connected time to be older than one week ago.
58+
// For the other half, set their last connected time to be within the last week.
59+
for i := 0; i < opts.NumAgents; i++ {
60+
var connectedAt time.Time
61+
if i%2 == 0 {
62+
connectedAt = weekAgo.AddDate(0, 0, -randintn(7))
63+
} else {
64+
connectedAt = now.AddDate(0, 0, -randintn(7))
65+
}
66+
setAgentLastConnectedAt(ctx, t, db, agentIDs[i], connectedAt)
6067
}
6168

6269
// Assert that some old logs exist

0 commit comments

Comments
 (0)