(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestValidatePath(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | input string |
| 13 | want string |
| 14 | }{ |
| 15 | {"/", ""}, |
| 16 | {"/foo", "/foo"}, |
| 17 | {"foo", "/foo"}, |
| 18 | {"/foo/", "/foo"}, |
| 19 | {"/foo/bar", "/foo/bar"}, |
| 20 | {"foo/bar/", "/foo/bar"}, |
| 21 | {"/foo//bar", "/foo/bar"}, |
| 22 | {"foo//bar/", "/foo/bar"}, |
| 23 | } |
| 24 | |
| 25 | for _, tt := range tests { |
| 26 | got, err := validatePath(tt.input) |
| 27 | if err != nil { |
| 28 | t.Errorf("validatePath(%q) returned error: %v", tt.input, err) |
| 29 | continue |
| 30 | } |
| 31 | if got != tt.want { |
| 32 | t.Errorf("validatePath(%q) = %q, want %q", tt.input, got, tt.want) |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func TestValidatePathRootBecomesEmpty(t *testing.T) { |
| 38 | got, err := validatePath("/") |
nothing calls this directly
no test coverage detected