forked from golangci/golangci-lint
/
processor_test.go
57 lines (45 loc) · 1.08 KB
/
processor_test.go
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
46
47
48
49
50
51
52
53
54
55
56
57
package processors
import (
"go/token"
"testing"
"github.com/stretchr/testify/assert"
"github.com/golangci/golangci-lint/pkg/result"
)
type issueTestCase struct {
Path string
Line int
Text string
Linter string
Severity string
}
func newIssueFromIssueTestCase(c issueTestCase) result.Issue {
return result.Issue{
Text: c.Text,
FromLinter: c.Linter,
Pos: token.Position{
Filename: c.Path,
Line: c.Line,
},
}
}
func newIssueFromTextTestCase(text string) result.Issue {
return result.Issue{
Text: text,
}
}
func process(t *testing.T, p Processor, issues ...result.Issue) []result.Issue {
t.Helper()
processedIssues, err := p.Process(issues)
assert.NoError(t, err)
return processedIssues
}
func processAssertSame(t *testing.T, p Processor, issues ...result.Issue) {
t.Helper()
processedIssues := process(t, p, issues...)
assert.Equal(t, issues, processedIssues)
}
func processAssertEmpty(t *testing.T, p Processor, issues ...result.Issue) {
t.Helper()
processedIssues := process(t, p, issues...)
assert.Empty(t, processedIssues)
}