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

Function TestMiddlewareGeneralCase

middleware_test.go:17–43  ·  middleware_test.go::TestMiddlewareGeneralCase
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestMiddlewareGeneralCase(t *testing.T) {
18 signature := ""
19 router := New()
20 router.Use(func(c *Context) {
21 signature += "A"
22 c.Next()
23 signature += "B"
24 })
25 router.Use(func(c *Context) {
26 signature += "C"
27 })
28 router.GET("/", func(c *Context) {
29 signature += "D"
30 })
31 router.NoRoute(func(c *Context) {
32 signature += " X "
33 })
34 router.NoMethod(func(c *Context) {
35 signature += " XX "
36 })
37 // RUN
38 w := PerformRequest(router, http.MethodGet, "/")
39
40 // TEST
41 assert.Equal(t, http.StatusOK, w.Code)
42 assert.Equal(t, "ACDB", signature)
43}
44
45func TestMiddlewareNoRoute(t *testing.T) {
46 signature := ""

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
PerformRequestFunction · 0.85
NextMethod · 0.80
NoRouteMethod · 0.80
NoMethodMethod · 0.80
UseMethod · 0.65
GETMethod · 0.65

Tested by

no test coverage detected