From 7e854adbb320dfdafb89e7784df4270df5ebf80a Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Tue, 21 Mar 2023 14:19:09 -0500 Subject: [PATCH] fix: poll audit logs to ensure write is last (#6708) --- coderd/workspaces_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index 199f05d737..0314c8f088 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -1261,8 +1261,12 @@ func TestWorkspaceUpdateAutostart(t *testing.T) { interval := next.Sub(testCase.at) require.Equal(t, testCase.expectedInterval, interval, "unexpected interval") - require.Len(t, auditor.AuditLogs, 7) - assert.Equal(t, database.AuditActionWrite, auditor.AuditLogs[6].Action) + require.Eventually(t, func() bool { + if len(auditor.AuditLogs) < 7 { + return false + } + return auditor.AuditLogs[6].Action == database.AuditActionWrite + }, testutil.WaitShort, testutil.IntervalFast) }) }