(t *testing.T)
| 669 | } |
| 670 | |
| 671 | func TestTreeWildcardConflictEx(t *testing.T) { |
| 672 | conflicts := [...]struct { |
| 673 | route string |
| 674 | segPath string |
| 675 | existPath string |
| 676 | existSegPath string |
| 677 | }{ |
| 678 | {"/who/are/foo", "/foo", `/who/are/\*you`, `/\*you`}, |
| 679 | {"/who/are/foo/", "/foo/", `/who/are/\*you`, `/\*you`}, |
| 680 | {"/who/are/foo/bar", "/foo/bar", `/who/are/\*you`, `/\*you`}, |
| 681 | {"/conxxx", "xxx", `/con:tact`, `:tact`}, |
| 682 | {"/conooo/xxx", "ooo", `/con:tact`, `:tact`}, |
| 683 | } |
| 684 | |
| 685 | for _, conflict := range conflicts { |
| 686 | // I have to re-create a 'tree', because the 'tree' will be |
| 687 | // in an inconsistent state when the loop recovers from the |
| 688 | // panic which threw by 'addRoute' function. |
| 689 | tree := &node{} |
| 690 | routes := [...]string{ |
| 691 | "/con:tact", |
| 692 | "/who/are/*you", |
| 693 | "/who/foo/hello", |
| 694 | } |
| 695 | |
| 696 | for _, route := range routes { |
| 697 | tree.addRoute(route, fakeHandler(route)) |
| 698 | } |
| 699 | |
| 700 | recv := catchPanic(func() { |
| 701 | tree.addRoute(conflict.route, fakeHandler(conflict.route)) |
| 702 | }) |
| 703 | |
| 704 | if !regexp.MustCompile(fmt.Sprintf("'%s' in new path .* conflicts with existing wildcard '%s' in existing prefix '%s'", conflict.segPath, conflict.existSegPath, conflict.existPath)).MatchString(fmt.Sprint(recv)) { |
| 705 | t.Fatalf("invalid wildcard conflict error (%v)", recv) |
| 706 | } |
| 707 | } |
| 708 | } |
nothing calls this directly
no test coverage detected