mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-24 08:18:52 -03:00
Extend & simplify the test for IsVendor (#45)
This commit is contained in:
parent
b60e5c6f5a
commit
d2d4c32d4d
@ -13,24 +13,54 @@ import (
|
|||||||
|
|
||||||
func TestIsVendor(t *testing.T) {
|
func TestIsVendor(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
|
||||||
path string
|
path string
|
||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{name: "TestIsVendor_1", path: "foo/bar", expected: false},
|
{"cache/", true},
|
||||||
{name: "TestIsVendor_2", path: "foo/vendor/foo", expected: true},
|
{"random/cache/", true},
|
||||||
{name: "TestIsVendor_3", path: ".sublime-project", expected: true},
|
{"cache", false},
|
||||||
{name: "TestIsVendor_4", path: "leaflet.draw-src.js", expected: true},
|
{"dependencies/", true},
|
||||||
{name: "TestIsVendor_5", path: "foo/bar/MochiKit.js", expected: true},
|
{"Dependencies/", true},
|
||||||
{name: "TestIsVendor_6", path: "foo/bar/dojo.js", expected: true},
|
{"dependency/", false},
|
||||||
{name: "TestIsVendor_7", path: "foo/env/whatever", expected: true},
|
{"dist/", true},
|
||||||
{name: "TestIsVendor_8", path: "foo/.imageset/bar", expected: true},
|
{"dist", false},
|
||||||
{name: "TestIsVendor_9", path: "Vagrantfile", expected: true},
|
{"random/dist/", true},
|
||||||
|
{"random/dist", false},
|
||||||
|
{"deps/", true},
|
||||||
|
{"configure", true},
|
||||||
|
{"a/configure", true},
|
||||||
|
{"config.guess", true},
|
||||||
|
{"config.guess/", false},
|
||||||
|
{".vscode/", true},
|
||||||
|
{"doc/_build/", true},
|
||||||
|
{"a/docs/_build/", true},
|
||||||
|
{"a/dasdocs/_build-vsdoc.js", true},
|
||||||
|
{"a/dasdocs/_build-vsdoc.j", false},
|
||||||
|
{"foo/bar", false},
|
||||||
|
{".sublime-project", true},
|
||||||
|
{"foo/vendor/foo", true},
|
||||||
|
{"leaflet.draw-src.js", true},
|
||||||
|
{"foo/bar/MochiKit.js", true},
|
||||||
|
{"foo/bar/dojo.js", true},
|
||||||
|
{"foo/env/whatever", true},
|
||||||
|
{"foo/.imageset/bar", true},
|
||||||
|
{"Vagrantfile", true},
|
||||||
}
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.path, func(t *testing.T) {
|
||||||
|
if got := IsVendor(tt.path); got != tt.expected {
|
||||||
|
t.Errorf("IsVendor() = %v, expected %v", got, tt.expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
func BenchmarkIsVendor(b *testing.B) {
|
||||||
is := IsVendor(test.path)
|
for i := 0; i < b.N; i++ {
|
||||||
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
IsVendor(".vscode/")
|
||||||
|
IsVendor("cache/")
|
||||||
|
IsVendor("foo/bar")
|
||||||
|
IsVendor("foo/bar/MochiKit.js")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user