(t *testing.T)
| 729 | } |
| 730 | |
| 731 | func TestRouteContextHoldsFullPath(t *testing.T) { |
| 732 | router := New() |
| 733 | |
| 734 | // Test routes |
| 735 | routes := []string{ |
| 736 | "/simple", |
| 737 | "/project/:name", |
| 738 | "/", |
| 739 | "/news/home", |
| 740 | "/news", |
| 741 | "/simple-two/one", |
| 742 | "/simple-two/one-two", |
| 743 | "/project/:name/build/*params", |
| 744 | "/project/:name/bui", |
| 745 | "/user/:id/status", |
| 746 | "/user/:id", |
| 747 | "/user/:id/profile", |
| 748 | } |
| 749 | |
| 750 | for _, route := range routes { |
| 751 | actualRoute := route |
| 752 | router.GET(route, func(c *Context) { |
| 753 | // For each defined route context should contain its full path |
| 754 | assert.Equal(t, actualRoute, c.FullPath()) |
| 755 | c.AbortWithStatus(http.StatusOK) |
| 756 | }) |
| 757 | } |
| 758 | |
| 759 | for _, route := range routes { |
| 760 | w := PerformRequest(router, http.MethodGet, route) |
| 761 | assert.Equal(t, http.StatusOK, w.Code) |
| 762 | } |
| 763 | |
| 764 | // Test not found |
| 765 | router.Use(func(c *Context) { |
| 766 | // For not found routes full path is empty |
| 767 | assert.Empty(t, c.FullPath()) |
| 768 | }) |
| 769 | |
| 770 | w := PerformRequest(router, http.MethodGet, "/not-found") |
| 771 | assert.Equal(t, http.StatusNotFound, w.Code) |
| 772 | } |
| 773 | |
| 774 | func TestEngineHandleMethodNotAllowedCornerCase(t *testing.T) { |
| 775 | r := New() |
nothing calls this directly
no test coverage detected