1
1
package config
2
2
3
3
import (
4
- "fmt "
4
+ "log "
5
5
"sort"
6
6
"testing"
7
7
@@ -10,45 +10,50 @@ import (
10
10
"github.com/golangci/golangci-lint/pkg/logutils"
11
11
)
12
12
13
- func TestUtils (t * testing.T ) {
13
+ func Test_intersectStringSlice (t * testing.T ) {
14
14
s1 := []string {"diagnostic" , "experimental" , "opinionated" }
15
15
s2 := []string {"opinionated" , "experimental" }
16
+
16
17
s3 := intersectStringSlice (s1 , s2 )
18
+
17
19
sort .Strings (s3 )
20
+
18
21
assert .Equal (t , s3 , []string {"experimental" , "opinionated" })
19
22
}
20
23
24
+ func Test_filterByDisableTags (t * testing.T ) {
25
+ disabledTags := []string {"experimental" , "opinionated" }
26
+ enabledChecks := []string {"appendAssign" , "sortSlice" , "caseOrder" , "dupImport" }
27
+
28
+ filterEnabledChecks := filterByDisableTags (enabledChecks , disabledTags , & tLog {})
29
+
30
+ sort .Strings (filterEnabledChecks )
31
+
32
+ assert .Equal (t , []string {"appendAssign" , "caseOrder" }, filterEnabledChecks )
33
+ }
34
+
21
35
type tLog struct {}
22
36
23
37
func (l * tLog ) Fatalf (format string , args ... interface {}) {
24
- fmt .Printf (fmt . Sprintf ( format , args ... ) + " \n " )
38
+ log .Printf (format , args ... )
25
39
}
26
40
27
41
func (l * tLog ) Panicf (format string , args ... interface {}) {
28
- fmt .Printf (fmt . Sprintf ( format , args ... ) + " \n " )
42
+ log .Printf (format , args ... )
29
43
}
30
44
31
45
func (l * tLog ) Errorf (format string , args ... interface {}) {
32
- fmt .Printf (fmt . Sprintf ( format , args ... ) + " \n " )
46
+ log .Printf (format , args ... )
33
47
}
34
48
35
49
func (l * tLog ) Warnf (format string , args ... interface {}) {
36
- fmt .Printf (fmt . Sprintf ( format , args ... ) + " \n " )
50
+ log .Printf (format , args ... )
37
51
}
38
52
39
53
func (l * tLog ) Infof (format string , args ... interface {}) {
40
- fmt .Printf (fmt . Sprintf ( format , args ... ) + " \n " )
54
+ log .Printf (format , args ... )
41
55
}
42
56
43
57
func (l * tLog ) Child (name string ) logutils.Log { return nil }
44
58
45
59
func (l * tLog ) SetLevel (level logutils.LogLevel ) {}
46
-
47
- func TestFilterByDisableTags (t * testing.T ) {
48
- testLog := & tLog {}
49
- disabledTags := []string {"experimental" , "opinionated" }
50
- enabledChecks := []string {"appendAssign" , "sortSlice" , "caseOrder" , "dupImport" }
51
- filterEnabledChecks := filterByDisableTags (enabledChecks , disabledTags , testLog )
52
- sort .Strings (filterEnabledChecks )
53
- assert .Equal (t , []string {"appendAssign" , "caseOrder" }, filterEnabledChecks )
54
- }
0 commit comments