-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
exclude_test.go
56 lines (40 loc) · 1.41 KB
/
exclude_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
package processors
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/result"
)
func TestExclude(t *testing.T) {
p := NewExclude(&config.Issues{ExcludePatterns: []string{"^exclude$"}})
texts := []string{"excLude", "1", "", "exclud", "notexclude"}
var issues []result.Issue
for _, t := range texts {
issues = append(issues, newIssueFromTextTestCase(t))
}
processedIssues := process(t, p, issues...)
assert.Len(t, processedIssues, len(issues)-1)
var processedTexts []string
for _, i := range processedIssues {
processedTexts = append(processedTexts, i.Text)
}
assert.Equal(t, texts[1:], processedTexts)
}
func TestExclude_empty(t *testing.T) {
processAssertSame(t, NewExclude(&config.Issues{}), newIssueFromTextTestCase("test"))
}
func TestExclude_caseSensitive(t *testing.T) {
p := NewExclude(&config.Issues{ExcludePatterns: []string{"^exclude$"}, ExcludeCaseSensitive: true})
texts := []string{"excLude", "1", "", "exclud", "exclude"}
var issues []result.Issue
for _, t := range texts {
issues = append(issues, newIssueFromTextTestCase(t))
}
processedIssues := process(t, p, issues...)
assert.Len(t, processedIssues, len(issues)-1)
var processedTexts []string
for _, i := range processedIssues {
processedTexts = append(processedTexts, i.Text)
}
assert.Equal(t, texts[:len(texts)-1], processedTexts)
}