Skip to content

Commit 6f06f8d

Browse files
authored
test: Fix test timeouts due to contexts created too early (#7242)
1 parent ea78ca5 commit 6f06f8d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

coderd/workspacebuilds_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,7 @@ func TestWorkspaceBuildState(t *testing.T) {
572572

573573
func TestWorkspaceBuildStatus(t *testing.T) {
574574
t.Parallel()
575-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
576-
defer cancel()
575+
577576
auditor := audit.NewMock()
578577
numLogs := len(auditor.AuditLogs())
579578
client, closeDaemon, api := coderdtest.NewWithAPI(t, &coderdtest.Options{IncludeProvisionerDaemon: true, Auditor: auditor})
@@ -597,6 +596,10 @@ func TestWorkspaceBuildStatus(t *testing.T) {
597596
closeDaemon = coderdtest.NewProvisionerDaemon(t, api)
598597
// after successful build is "running"
599598
_ = coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
599+
600+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
601+
defer cancel()
602+
600603
workspace, err := client.Workspace(ctx, workspace.ID)
601604
require.NoError(t, err)
602605
require.EqualValues(t, codersdk.WorkspaceStatusRunning, workspace.LatestBuild.Status)

enterprise/coderd/templates_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,6 @@ func TestReadFileWithTemplateUpdate(t *testing.T) {
980980
t.Parallel()
981981
t.Run("HasTemplateUpdate", func(t *testing.T) {
982982
t.Parallel()
983-
ctx := testutil.Context(t, testutil.WaitMedium)
984983

985984
// Upload a file
986985
client := coderdenttest.New(t, nil)
@@ -991,6 +990,8 @@ func TestReadFileWithTemplateUpdate(t *testing.T) {
991990
},
992991
})
993992

993+
ctx := testutil.Context(t, testutil.WaitLong)
994+
994995
resp, err := client.Upload(ctx, codersdk.ContentTypeTar, bytes.NewReader(make([]byte, 1024)))
995996
require.NoError(t, err)
996997

0 commit comments

Comments
 (0)