Skip to content

Commit 69f27ef

Browse files
authored
fix: Close parameter file before test exit (#2694)
Flake seen here: https://github.com/coder/coder/runs/7079404499?check_suite_focus=true
1 parent abfae1b commit 69f27ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cli/create_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ func TestCreate(t *testing.T) {
273273
})
274274

275275
tempDir := t.TempDir()
276-
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
276+
parameterFile, err := os.CreateTemp(tempDir, "testParameterFile*.yaml")
277+
require.NoError(t, err)
278+
defer parameterFile.Close()
277279
_, _ = parameterFile.WriteString(fmt.Sprintf("%s: %q", echo.ParameterExecKey, echo.ParameterError("fail")))
278280

279281
// The template import job should end up failed, but we need it to be
@@ -288,7 +290,7 @@ func TestCreate(t *testing.T) {
288290
cmd.SetIn(pty.Input())
289291
cmd.SetOut(pty.Output())
290292

291-
err := cmd.Execute()
293+
err = cmd.Execute()
292294
require.Error(t, err)
293295
require.ErrorContains(t, err, "dry-run workspace")
294296
})

0 commit comments

Comments
 (0)