Skip to content

Commit 6683ad9

Browse files
authored
test(coderd): fix TestWorkspaceBuild flake (coder#10387)
Fixes coder#10335
1 parent 8f1b4fb commit 6683ad9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

coderd/workspacebuilds_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ func TestWorkspaceBuild(t *testing.T) {
4848
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
4949
auditor.ResetLogs()
5050
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
51-
52-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
53-
defer cancel()
54-
55-
_, err := client.WorkspaceBuild(ctx, workspace.LatestBuild.ID)
56-
require.NoError(t, err)
57-
require.Len(t, auditor.AuditLogs(), 1)
51+
_ = coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
52+
// Create workspace will also start a build, so we need to wait for
53+
// it to ensure all events are recorded.
54+
require.Len(t, auditor.AuditLogs(), 2)
5855
require.Equal(t, auditor.AuditLogs()[0].Ip.IPNet.IP.String(), "127.0.0.1")
56+
require.Equal(t, auditor.AuditLogs()[1].Ip.IPNet.IP.String(), "127.0.0.1")
5957
}
6058

6159
func TestWorkspaceBuildByBuildNumber(t *testing.T) {

0 commit comments

Comments
 (0)