(t *testing.T)
| 940 | } |
| 941 | |
| 942 | func TestTreeWildcardConflictEx(t *testing.T) { |
| 943 | conflicts := [...]struct { |
| 944 | route string |
| 945 | segPath string |
| 946 | existPath string |
| 947 | existSegPath string |
| 948 | }{ |
| 949 | {"/who/are/foo", "/foo", `/who/are/\*you`, `/\*you`}, |
| 950 | {"/who/are/foo/", "/foo/", `/who/are/\*you`, `/\*you`}, |
| 951 | {"/who/are/foo/bar", "/foo/bar", `/who/are/\*you`, `/\*you`}, |
| 952 | {"/con:nection", ":nection", `/con:tact`, `:tact`}, |
| 953 | } |
| 954 | |
| 955 | for _, conflict := range conflicts { |
| 956 | // I have to re-create a 'tree', because the 'tree' will be |
| 957 | // in an inconsistent state when the loop recovers from the |
| 958 | // panic which threw by 'addRoute' function. |
| 959 | tree := &node{} |
| 960 | routes := [...]string{ |
| 961 | "/con:tact", |
| 962 | "/who/are/*you", |
| 963 | "/who/foo/hello", |
| 964 | } |
| 965 | |
| 966 | for _, route := range routes { |
| 967 | tree.addRoute(route, fakeHandler(route)) |
| 968 | } |
| 969 | |
| 970 | recv := catchPanic(func() { |
| 971 | tree.addRoute(conflict.route, fakeHandler(conflict.route)) |
| 972 | }) |
| 973 | |
| 974 | 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)) { |
| 975 | t.Fatalf("invalid wildcard conflict error (%v)", recv) |
| 976 | } |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | func TestTreeInvalidEscape(t *testing.T) { |
| 981 | routes := map[string]bool{ |
nothing calls this directly
no test coverage detected