/
path_test.go
57 lines (54 loc) · 974 Bytes
/
path_test.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package util
import (
"testing"
)
func TestSafeTrimGlobsAndSlashes(t *testing.T) {
tests := []struct {
name string
path string
want string
}{
{
name: "globs",
path: "**/*",
want: "",
},
{
name: "empty path",
path: "",
want: "",
},
{
name: "path",
path: "path",
want: "path",
},
{
name: "path with trailing slash",
path: "path/",
want: "path",
},
{
name: "path with globs and slashes",
path: "path/**/*",
want: "path",
},
{
name: "path with glob as part of a directory or file name 1",
path: "path/name-*",
want: "path/name-*",
},
{
name: "path with glob as part of a directory or file name 2",
path: "path/*.tmp",
want: "path/*.tmp",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SafeTrimGlobsAndSlashesFromPath(tt.path); got != tt.want {
t.Errorf("SafeTrimGlobsAndSlashesFromPath() = %v, want %v", got, tt.want)
}
})
}
}