From 0a7c21eb00522faa44fad7e58382c830eb1d856c Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Sun, 18 Sep 2022 21:03:59 +0000 Subject: [PATCH] fix: Test race for TestPostWorkspaceBuild The job could run before the state was fetched, which resulted in an empty state being returned. --- coderd/workspaces_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index bbaba4e37924c..11e23ea341c60 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -830,7 +830,7 @@ func TestPostWorkspaceBuild(t *testing.T) { t.Run("WithState", func(t *testing.T) { t.Parallel() - client := coderdtest.New(t, &coderdtest.Options{ + client, closeDaemon := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{ IncludeProvisionerDaemon: true, }) user := coderdtest.CreateFirstUser(t, client) @@ -840,6 +840,7 @@ func TestPostWorkspaceBuild(t *testing.T) { workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID) wantState := []byte("something") + _ = closeDaemon.Close() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) defer cancel()