forked from golangci/golines
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathignored_test.go
More file actions
45 lines (39 loc) · 902 Bytes
/
Copy pathignored_test.go
File metadata and controls
45 lines (39 loc) · 902 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
41
42
43
44
45
package main
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_isGenerated(t *testing.T) {
testCases := []struct {
desc string
file string
assert assert.BoolAssertionFunc
}{
{
desc: "license before comment about generated code",
file: "testdata/generated_license.go",
assert: assert.True,
},
{
desc: "license before comment about generated code (star)",
file: "testdata/generated_license_star.go",
assert: assert.True,
},
{
desc: "no generated code comment",
file: "testdata/not_generated.go",
assert: assert.False,
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
content, err := os.ReadFile(filepath.FromSlash(test.file))
require.NoError(t, err)
test.assert(t, isGenerated(content))
})
}
}