MCPcopy
hub / github.com/labstack/echo / TestGroupRouteMiddlewareWithMatchAny

Function TestGroupRouteMiddlewareWithMatchAny

group_test.go:126–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestGroupRouteMiddlewareWithMatchAny(t *testing.T) {
127 // Ensure middleware and match any routes do not conflict
128 e := New()
129 g := e.Group("/group")
130 m1 := func(next HandlerFunc) HandlerFunc {
131 return func(c *Context) error {
132 return next(c)
133 }
134 }
135 m2 := func(next HandlerFunc) HandlerFunc {
136 return func(c *Context) error {
137 return c.String(http.StatusOK, c.RouteInfo().Path)
138 }
139 }
140 h := func(c *Context) error {
141 return c.String(http.StatusOK, c.RouteInfo().Path)
142 }
143 g.Use(m1)
144 g.GET("/help", h, m2)
145 g.GET("/*", h, m2)
146 g.GET("", h, m2)
147 e.GET("unrelated", h, m2)
148 e.GET("*", h, m2)
149
150 _, m := request(http.MethodGet, "/group/help", e)
151 assert.Equal(t, "/group/help", m)
152 _, m = request(http.MethodGet, "/group/help/other", e)
153 assert.Equal(t, "/group/*", m)
154 _, m = request(http.MethodGet, "/group/404", e)
155 assert.Equal(t, "/group/*", m)
156 _, m = request(http.MethodGet, "/group", e)
157 assert.Equal(t, "/group", m)
158 _, m = request(http.MethodGet, "/other", e)
159 assert.Equal(t, "/*", m)
160 _, m = request(http.MethodGet, "/", e)
161 assert.Equal(t, "/*", m)
162
163}
164
165func TestGroup_CONNECT(t *testing.T) {
166 e := New()

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
requestFunction · 0.85
RouteInfoMethod · 0.80
GroupMethod · 0.45
StringMethod · 0.45
UseMethod · 0.45
GETMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…