Skip to content

Commit 1ee6b8d

Browse files
authored
chore: fix flake in TestWorkspaceBuildsProvisionerState (#18839)
Fixes coder/internal#761
1 parent 7c077d3 commit 1ee6b8d

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

coderd/workspacebuilds_test.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,14 @@ func TestWorkspaceBuildsProvisionerState(t *testing.T) {
494494
require.NoError(t, err)
495495
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, build.ID)
496496

497-
// Validate that the deletion was audited.
498-
require.True(t, auditor.Contains(t, database.AuditLog{
499-
ResourceID: build.ID,
500-
Action: database.AuditActionDelete,
501-
}))
497+
// Validate that the deletion was audited. This happens after the transaction
498+
// is committed, so it may not show up in the mock auditor immediately.
499+
testutil.Eventually(ctx, t, func(context.Context) bool {
500+
return auditor.Contains(t, database.AuditLog{
501+
ResourceID: build.ID,
502+
Action: database.AuditActionDelete,
503+
})
504+
}, testutil.IntervalFast)
502505
})
503506

504507
t.Run("NoProvisioners", func(t *testing.T) {
@@ -535,11 +538,14 @@ func TestWorkspaceBuildsProvisionerState(t *testing.T) {
535538
require.Empty(t, ws)
536539
require.Equal(t, http.StatusGone, coderdtest.SDKError(t, err).StatusCode())
537540

538-
// Validate that the deletion was audited.
539-
require.True(t, auditor.Contains(t, database.AuditLog{
540-
ResourceID: build.ID,
541-
Action: database.AuditActionDelete,
542-
}))
541+
// Validate that the deletion was audited. This happens after the transaction
542+
// is committed, so it may not show up in the mock auditor immediately.
543+
testutil.Eventually(ctx, t, func(context.Context) bool {
544+
return auditor.Contains(t, database.AuditLog{
545+
ResourceID: build.ID,
546+
Action: database.AuditActionDelete,
547+
})
548+
}, testutil.IntervalFast)
543549
})
544550
})
545551
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy