Skip to content

Commit 5ed3c41

Browse files
authored
chore(coderd): fix test flake in TestWorkspaceUpdateAutomaticUpdates_OK (#11521)
1 parent 61cd9f0 commit 5ed3c41

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

coderd/workspaces_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,12 +2147,17 @@ func TestWorkspaceUpdateAutomaticUpdates_OK(t *testing.T) {
21472147
require.Equal(t, codersdk.AutomaticUpdatesAlways, updated.AutomaticUpdates)
21482148

21492149
require.Eventually(t, func() bool {
2150-
return len(auditor.AuditLogs()) >= 9
2151-
}, testutil.WaitShort, testutil.IntervalFast)
2152-
l := auditor.AuditLogs()[8]
2153-
require.Equal(t, database.AuditActionWrite, l.Action)
2154-
require.Equal(t, user.ID, l.UserID)
2155-
require.Equal(t, workspace.ID, l.ResourceID)
2150+
var found bool
2151+
for _, l := range auditor.AuditLogs() {
2152+
if l.Action == database.AuditActionWrite &&
2153+
l.UserID == user.ID &&
2154+
l.ResourceID == workspace.ID {
2155+
found = true
2156+
break
2157+
}
2158+
}
2159+
return found
2160+
}, testutil.WaitShort, testutil.IntervalFast, "did not find expected audit log")
21562161
}
21572162

21582163
func TestUpdateWorkspaceAutomaticUpdates_NotFound(t *testing.T) {

0 commit comments

Comments
 (0)