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

Function TestGroup_withoutRouteWillNotExecuteMiddleware

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

Source from the content-addressed store, hash-verified

15)
16
17func TestGroup_withoutRouteWillNotExecuteMiddleware(t *testing.T) {
18 e := New()
19
20 called := false
21 mw := func(next HandlerFunc) HandlerFunc {
22 return func(c *Context) error {
23 called = true
24 return c.NoContent(http.StatusTeapot)
25 }
26 }
27 // even though group has middleware it will not be executed when there are no routes under that group
28 _ = e.Group("/group", mw)
29
30 status, body := request(http.MethodGet, "/group/nope", e)
31 assert.Equal(t, http.StatusNotFound, status)
32 assert.Equal(t, `{"message":"Not Found"}`+"\n", body)
33
34 assert.False(t, called)
35}
36
37func TestGroup_withRoutesWillNotExecuteMiddlewareFor404(t *testing.T) {
38 e := New()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
requestFunction · 0.85
NoContentMethod · 0.80
GroupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…