-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmod_test.go
More file actions
40 lines (33 loc) · 787 Bytes
/
mod_test.go
File metadata and controls
40 lines (33 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package testutil_test
import (
"os"
"path/filepath"
"strings"
"testing"
"golang.org/x/tools/go/analysis/analysistest"
"github.com/gostaticanalysis/testutil"
)
func TestWithModules_LineComment(t *testing.T) {
t.Parallel()
testdata := testutil.WithModules(t, analysistest.TestData(), nil)
tests := []struct {
path string
want string
}{
{filepath.Join(testdata, "src", "a", "a.go"), "//line a.go:1"},
{filepath.Join(testdata, "src", "a", "b", "b.go"), "//line b/b.go:1"},
}
for _, tt := range tests {
t.Run(tt.path, func(t *testing.T) {
t.Parallel()
src, err := os.ReadFile(tt.path)
if err != nil {
t.Fatal(err)
}
got, _, _ := strings.Cut(string(src), "\n")
if got != tt.want {
t.Errorf("got %q, want %q", got, tt.want)
}
})
}
}