| 345 | } |
| 346 | |
| 347 | func TestParseError(t *testing.T) { |
| 348 | for _, spec := range []struct { |
| 349 | input string |
| 350 | wantError error |
| 351 | }{ |
| 352 | { |
| 353 | input: "v1/{name}", |
| 354 | wantError: InvalidTemplateError{ |
| 355 | tmpl: "v1/{name}", |
| 356 | msg: "no leading /", |
| 357 | }, |
| 358 | }, |
| 359 | } { |
| 360 | _, err := Parse(spec.input) |
| 361 | if err == nil { |
| 362 | t.Errorf("Parse(%q) unexpectedly did not fail", spec.input) |
| 363 | continue |
| 364 | } |
| 365 | if !errors.Is(err, spec.wantError) { |
| 366 | t.Errorf("Error did not match expected error: got %v wanted %v", err, spec.wantError) |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | func TestParseSegmentsWithErrors(t *testing.T) { |
| 372 | for _, spec := range []struct { |