Skip to content

Commit 9acc74e

Browse files
committed
Fix lint and use test tempdir for output file
1 parent 2f423b6 commit 9acc74e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

test/linters_test.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package test
33
import (
44
"bufio"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"os/exec"
8+
"path"
99
"path/filepath"
1010
"strings"
1111
"testing"
@@ -134,12 +134,7 @@ func TestStderrOutput(t *testing.T) {
134134
}
135135

136136
func TestFileOutput(t *testing.T) {
137-
f, err := os.CreateTemp("", "golangci_lint_test_result")
138-
require.NoError(t, err)
139-
f.Close()
140-
141-
resultPath := f.Name()
142-
defer os.Remove(resultPath)
137+
resultPath := path.Join(t.TempDir(), "golangci_lint_test_result")
143138

144139
sourcePath := filepath.Join(testdataDir, "gci", "gci.go")
145140
args := []string{
@@ -157,7 +152,7 @@ func TestFileOutput(t *testing.T) {
157152
ExpectHasIssue("testdata/gci/gci.go:7: File is not `gci`-ed").
158153
ExpectOutputNotContains(`"Issues":[`)
159154

160-
b, err := ioutil.ReadFile(resultPath)
155+
b, err := os.ReadFile(resultPath)
161156
require.NoError(t, err)
162157
require.Contains(t, string(b), `"Issues":[`)
163158
}

0 commit comments

Comments
 (0)