From e05e65543d54ba7a48819a6def37e19a732304c9 Mon Sep 17 00:00:00 2001 From: kylecarbs Date: Mon, 27 Jun 2022 19:09:48 +0000 Subject: [PATCH] fix: Close parameter file before test exit Flake seen here: https://github.com/coder/coder/runs/7079404499?check_suite_focus=true --- cli/create_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/create_test.go b/cli/create_test.go index 453bdbfbd1b9e..625edd87411f3 100644 --- a/cli/create_test.go +++ b/cli/create_test.go @@ -273,7 +273,9 @@ func TestCreate(t *testing.T) { }) tempDir := t.TempDir() - parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml") + parameterFile, err := os.CreateTemp(tempDir, "testParameterFile*.yaml") + require.NoError(t, err) + defer parameterFile.Close() _, _ = parameterFile.WriteString(fmt.Sprintf("%s: %q", echo.ParameterExecKey, echo.ParameterError("fail"))) // The template import job should end up failed, but we need it to be @@ -288,7 +290,7 @@ func TestCreate(t *testing.T) { cmd.SetIn(pty.Input()) cmd.SetOut(pty.Output()) - err := cmd.Execute() + err = cmd.Execute() require.Error(t, err) require.ErrorContains(t, err, "dry-run workspace") })