| 1 |
package desync |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/stretchr/testify/require" |
| 7 |
) |
| 8 |
|
| 9 |
func TestNormalizeGCPrefix(t *testing.T) { |
| 10 |
|
| 11 |
tests := map[string]struct { |
| 12 |
path string |
| 13 |
expectedPrefix string |
| 14 |
}{ |
| 15 |
"blank path": {"", ""}, |
| 16 |
"slash only": {"/", ""}, |
| 17 |
"path with no slash": {"path", "path/"}, |
| 18 |
"path with leading slash": {"/path", "path/"}, |
| 19 |
"path with trailing slash": {"path/", "path/"}, |
| 20 |
"paths with no slashes": {"path1/path2", "path1/path2/"}, |
| 21 |
"paths with leading slash": {"/path1/path2", "path1/path2/"}, |
| 22 |
"paths with trailing slash": {"path1/path2/", "path1/path2/"}, |
| 23 |
"paths with leading and trailing slashes": {"path1/path2/", "path1/path2/"}, |
| 24 |
} |
| 25 |
|
| 26 |
for name, test := range tests { |
| 27 |
t.Run(name, func(t *testing.T) { |
| 28 |
|
| 29 |
prefix := normalizeGCPrefix(test.path) |
| 30 |
|
| 31 |
require.Equal(t, test.expectedPrefix, prefix) |
| 32 |
}) |
| 33 |
} |
| 34 |
} |