MCPcopy
hub / github.com/gin-gonic/gin / TestListOfRoutes

Function TestListOfRoutes

gin_test.go:612–652  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

610}
611
612func TestListOfRoutes(t *testing.T) {
613 router := New()
614 router.GET("/favicon.ico", handlerTest1)
615 router.GET("/", handlerTest1)
616 group := router.Group("/users")
617 {
618 group.GET("/", handlerTest2)
619 group.GET("/:id", handlerTest1)
620 group.POST("/:id", handlerTest2)
621 }
622 router.Static("/static", ".")
623
624 list := router.Routes()
625
626 assert.Len(t, list, 7)
627 assertRoutePresent(t, list, RouteInfo{
628 Method: http.MethodGet,
629 Path: "/favicon.ico",
630 Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
631 })
632 assertRoutePresent(t, list, RouteInfo{
633 Method: http.MethodGet,
634 Path: "/",
635 Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
636 })
637 assertRoutePresent(t, list, RouteInfo{
638 Method: http.MethodGet,
639 Path: "/users/",
640 Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest2$",
641 })
642 assertRoutePresent(t, list, RouteInfo{
643 Method: http.MethodGet,
644 Path: "/users/:id",
645 Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
646 })
647 assertRoutePresent(t, list, RouteInfo{
648 Method: http.MethodPost,
649 Path: "/users/:id",
650 Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest2$",
651 })
652}
653
654func TestEngineHandleContext(t *testing.T) {
655 r := New()

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
assertRoutePresentFunction · 0.85
RoutesMethod · 0.80
GETMethod · 0.65
GroupMethod · 0.65
POSTMethod · 0.65
StaticMethod · 0.65

Tested by

no test coverage detected