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

Function TestGroup_withRoutesWillNotExecuteMiddlewareFor404

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

Source from the content-addressed store, hash-verified

35}
36
37func TestGroup_withRoutesWillNotExecuteMiddlewareFor404(t *testing.T) {
38 e := New()
39
40 called := false
41 mw := func(next HandlerFunc) HandlerFunc {
42 return func(c *Context) error {
43 called = true
44 return c.NoContent(http.StatusTeapot)
45 }
46 }
47 // even though group has middleware and routes when we have no match on some route the middlewares for that
48 // group will not be executed
49 g := e.Group("/group", mw)
50 g.GET("/yes", handlerFunc)
51
52 status, body := request(http.MethodGet, "/group/nope", e)
53 assert.Equal(t, http.StatusNotFound, status)
54 assert.Equal(t, `{"message":"Not Found"}`+"\n", body)
55
56 assert.False(t, called)
57}
58
59func TestGroup_multiLevelGroup(t *testing.T) {
60 e := New()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…