/
config_gocritic_test.go
54 lines (41 loc) · 1.46 KB
/
config_gocritic_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
package config
import (
"fmt"
"sort"
"testing"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/stretchr/testify/assert"
)
func TestUtils(t *testing.T) {
s1 := []string{"diagnostic", "experimental", "opinionated"}
s2 := []string{"opinionated", "experimental"}
s3 := intersectStringSlice(s1, s2)
sort.Strings(s3)
assert.Equal(t, s3, []string{"experimental", "opinionated"})
}
type tLog struct{}
func (l *tLog) Fatalf(format string, args ...interface{}) {
fmt.Printf(fmt.Sprintf(format, args...) + "\n")
}
func (l *tLog) Panicf(format string, args ...interface{}) {
fmt.Printf(fmt.Sprintf(format, args...) + "\n")
}
func (l *tLog) Errorf(format string, args ...interface{}) {
fmt.Printf(fmt.Sprintf(format, args...) + "\n")
}
func (l *tLog) Warnf(format string, args ...interface{}) {
fmt.Printf(fmt.Sprintf(format, args...) + "\n")
}
func (l *tLog) Infof(format string, args ...interface{}) {
fmt.Printf(fmt.Sprintf(format, args...) + "\n")
}
func (l *tLog) Child(name string) logutils.Log { return nil }
func (l *tLog) SetLevel(level logutils.LogLevel) {}
func TestFilterByDisableTags(t *testing.T) {
testLog := &tLog{}
disabledTags := []string{"experimental", "opinionated"}
enabledChecks := []string{"appendAssign", "sortSlice", "caseOrder", "dupImport"}
filterEnabledChecks := filterByDisableTags(enabledChecks, disabledTags, testLog)
sort.Strings(filterEnabledChecks)
assert.Equal(t, []string{"appendAssign", "caseOrder"}, filterEnabledChecks)
}