-
Notifications
You must be signed in to change notification settings - Fork 43
/
gcs_test.go
34 lines (28 loc) · 1.05 KB
/
gcs_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
package desync
import (
"testing"
)
func TestNormalizeGCPrefix(t *testing.T) {
tests := map[string]struct {
path string
expectedPrefix string
}{
"blank path": {"", ""},
"slash only": {"/", ""},
"path with no slash": {"path", "path/"},
"path with leading slash": {"/path", "path/"},
"path with trailing slash": {"path/", "path/"},
"paths with no slashes": {"path1/path2", "path1/path2/"},
"paths with leading slash": {"/path1/path2", "path1/path2/"},
"paths with trailing slash": {"path1/path2/", "path1/path2/"},
"paths with leading and trailing slashes": {"path1/path2/", "path1/path2/"},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
prefix := normalizeGCPrefix(test.path)
if prefix != test.expectedPrefix {
t.Fatalf("path '%s' should normalize into '%s' but was normalized into '%s'", test.path, test.expectedPrefix, prefix)
}
})
}
}