golangci-lint/pkg/config/config_gocritic_test.go
dependabot[bot] 6ac41d9f33
build(deps): bump github.com/go-critic/go-critic from 0.5.0 to 0.5.2 (#1307)
* build(deps): bump github.com/go-critic/go-critic from 0.5.0 to 0.5.2

Bumps [github.com/go-critic/go-critic](https://github.com/go-critic/go-critic) from 0.5.0 to 0.5.2.
- [Release notes](https://github.com/go-critic/go-critic/releases)
- [Commits](https://github.com/go-critic/go-critic/compare/v0.5.0...v0.5.2)

Signed-off-by: dependabot[bot] <support@github.com>

* Fix gocritic TestFilterByDisableTags

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergey Vilgelm <sergey.vilgelm@ibm.com>
2020-08-17 08:38:53 -05:00

55 lines
1.5 KiB
Go

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)
}