Skip to content

Commit 004175f

Browse files
committed
set last connected at for other agents
1 parent 3b79b5b commit 004175f

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
@@ -44,10 +44,17 @@ func TestPurge(t *testing.T) {
4444

4545
agentIDs, _ := seed(ctx, t, db, opts)
4646

47-
// For half of the agents, set their last connected time to one week ago plus some non-zero interval
48-
for i := 0; i < opts.NumAgents/2; i++ {
49-
randOldTime := weekAgo.AddDate(0, 0, -randintn(7))
50-
setAgentLastConnectedAt(ctx, t, db, agentIDs[i], randOldTime)
47+
// Set last connectd time for agents.
48+
// For half of the agents, set their last connected time to be older than one week ago.
49+
// For the other half, set their last connected time to be within the last week.
50+
for i := 0; i < opts.NumAgents; i++ {
51+
var connectedAt time.Time
52+
if i%2 == 0 {
53+
connectedAt = weekAgo.AddDate(0, 0, -randintn(7))
54+
} else {
55+
connectedAt = now.AddDate(0, 0, -randintn(7))
56+
}
57+
setAgentLastConnectedAt(ctx, t, db, agentIDs[i], connectedAt)
5158
}
5259

5360
// Assert that some old logs exist

0 commit comments

Comments
 (0)