forked from alecthomas/gometalinter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectives_test.go
42 lines (38 loc) · 844 Bytes
/
directives_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIgnoreRangeMatch(t *testing.T) {
var testcases = []struct {
doc string
issue Issue
linters []string
expected bool
}{
{
doc: "unmatched line",
issue: Issue{Line: 100},
},
{
doc: "matched line, all linters",
issue: Issue{Line: 5},
expected: true,
},
{
doc: "matched line, unmatched linter",
issue: Issue{Line: 5},
linters: []string{"vet"},
},
{
doc: "matched line and linters",
issue: Issue{Line: 20, Linter: "vet"},
linters: []string{"vet"},
expected: true,
},
}
for _, testcase := range testcases {
ir := ignoredRange{col: 20, start: 5, end: 20, linters: testcase.linters}
assert.Equal(t, testcase.expected, ir.matches(&testcase.issue), testcase.doc)
}
}