Skip to content

Commit

Permalink
Fix lint and use test tempdir for output file
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks committed Dec 1, 2021
1 parent 2f423b6 commit 9acc74e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions test/linters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package test
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -134,12 +134,7 @@ func TestStderrOutput(t *testing.T) {
}

func TestFileOutput(t *testing.T) {
f, err := os.CreateTemp("", "golangci_lint_test_result")
require.NoError(t, err)
f.Close()

resultPath := f.Name()
defer os.Remove(resultPath)
resultPath := path.Join(t.TempDir(), "golangci_lint_test_result")

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

b, err := ioutil.ReadFile(resultPath)
b, err := os.ReadFile(resultPath)
require.NoError(t, err)
require.Contains(t, string(b), `"Issues":[`)
}
Expand Down

0 comments on commit 9acc74e

Please sign in to comment.