| 435 | } |
| 436 | |
| 437 | func TestAddRoute(t *testing.T) { |
| 438 | router := New() |
| 439 | router.addRoute(http.MethodGet, "/", HandlersChain{func(_ *Context) {}}) |
| 440 | |
| 441 | assert.Len(t, router.trees, 1) |
| 442 | assert.NotNil(t, router.trees.get(http.MethodGet)) |
| 443 | assert.Nil(t, router.trees.get(http.MethodPost)) |
| 444 | |
| 445 | router.addRoute(http.MethodPost, "/", HandlersChain{func(_ *Context) {}}) |
| 446 | |
| 447 | assert.Len(t, router.trees, 2) |
| 448 | assert.NotNil(t, router.trees.get(http.MethodGet)) |
| 449 | assert.NotNil(t, router.trees.get(http.MethodPost)) |
| 450 | |
| 451 | router.addRoute(http.MethodPost, "/post", HandlersChain{func(_ *Context) {}}) |
| 452 | assert.Len(t, router.trees, 2) |
| 453 | } |
| 454 | |
| 455 | func TestAddRouteFails(t *testing.T) { |
| 456 | router := New() |