@@ -494,11 +494,14 @@ func TestWorkspaceBuildsProvisionerState(t *testing.T) {
494
494
require .NoError (t ,err )
495
495
coderdtest .AwaitWorkspaceBuildJobCompleted (t ,client ,build .ID )
496
496
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 )
502
505
})
503
506
504
507
t .Run ("NoProvisioners" ,func (t * testing.T ) {
@@ -535,11 +538,14 @@ func TestWorkspaceBuildsProvisionerState(t *testing.T) {
535
538
require .Empty (t ,ws )
536
539
require .Equal (t ,http .StatusGone ,coderdtest .SDKError (t ,err ).StatusCode ())
537
540
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 )
543
549
})
544
550
})
545
551
}