golangci-lint/pkg/packages/skip_test.go
Denis Isaev 3345c7136f fix #264: fix Windows compatibility
Fix skip-dirs regexps and 'go env' on Windows.
2018-11-05 12:54:40 +03:00

39 lines
748 B
Go

package packages
import (
"regexp"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPathElemRe(t *testing.T) {
matches := [][]string{
{"dir"},
{"root", "dir"},
{"root", "dir", "subdir"},
{"dir", "subdir"},
}
noMatches := [][]string{
{"nodir"},
{"dirno"},
{"root", "dirno"},
{"root", "nodir"},
{"root", "dirno", "subdir"},
{"root", "nodir", "subdir"},
{"dirno", "subdir"},
{"nodir", "subdir"},
}
for _, sep := range []rune{'/', '\\'} {
reStr := pathElemReImpl("dir", sep)
re := regexp.MustCompile(reStr)
for _, m := range matches {
assert.Regexp(t, re, strings.Join(m, string(sep)))
}
for _, m := range noMatches {
assert.NotRegexp(t, re, strings.Join(m, string(sep)))
}
}
}