From 5ed3c413cd018bfcdea2300f6fb82e1146934593 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 10 Jan 2024 08:45:32 +0000 Subject: [PATCH] chore(coderd): fix test flake in TestWorkspaceUpdateAutomaticUpdates_OK (#11521) --- coderd/workspaces_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index 69ab38d8ca..18566f6b3c 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -2147,12 +2147,17 @@ func TestWorkspaceUpdateAutomaticUpdates_OK(t *testing.T) { require.Equal(t, codersdk.AutomaticUpdatesAlways, updated.AutomaticUpdates) require.Eventually(t, func() bool { - return len(auditor.AuditLogs()) >= 9 - }, testutil.WaitShort, testutil.IntervalFast) - l := auditor.AuditLogs()[8] - require.Equal(t, database.AuditActionWrite, l.Action) - require.Equal(t, user.ID, l.UserID) - require.Equal(t, workspace.ID, l.ResourceID) + var found bool + for _, l := range auditor.AuditLogs() { + if l.Action == database.AuditActionWrite && + l.UserID == user.ID && + l.ResourceID == workspace.ID { + found = true + break + } + } + return found + }, testutil.WaitShort, testutil.IntervalFast, "did not find expected audit log") } func TestUpdateWorkspaceAutomaticUpdates_NotFound(t *testing.T) {