-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain_test.go
More file actions
29 lines (25 loc) · 808 Bytes
/
main_test.go
File metadata and controls
29 lines (25 loc) · 808 Bytes
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
package main
import (
"testing"
)
func TestFileMatch(t *testing.T) {
cases := []struct {
name string
path string
match bool
}{
{"go path matches", "teamserverlesss/foo/bar/utils.go", true},
{"non-go path does not match", "teamserverlesss/foo/bar/utils.py", false},
{"relative vendor path matches", "vendor/github.com/teamserverlesss/foo/bar/utils.go", false},
{"absolute vendor path matches", "/vendor/github.com/teamserverlesss/foo/bar/utils.go", false},
{"non-go path in vendor does not match", "/vendor/github.com/teamserverlesss/foo/bar/utils.yaml", false},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
isMatch := matchValidFile(tc.path)
if isMatch != tc.match {
t.Errorf("expected %v, got %v for %s", tc.match, isMatch, tc.path)
}
})
}
}