MCPcopy
hub / github.com/gofiber/fiber / Test_App_Chaining

Function Test_App_Chaining

app_test.go:1137–1164  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1135}
1136
1137func Test_App_Chaining(t *testing.T) {
1138 t.Parallel()
1139 n := func(c Ctx) error {
1140 return c.Next()
1141 }
1142 app := New()
1143 app.Use("/john", n, n, n, n, func(c Ctx) error {
1144 return c.SendStatus(202)
1145 })
1146 // check handler count for registered HEAD route
1147 require.Len(t, app.stack[app.methodInt(MethodHead)][0].Handlers, 5, "app.Test(req)")
1148
1149 req := httptest.NewRequest(MethodPost, "/john", http.NoBody)
1150
1151 resp, err := app.Test(req)
1152 require.NoError(t, err, "app.Test(req)")
1153 require.Equal(t, 202, resp.StatusCode, "Status code")
1154
1155 app.Get("/test", n, n, n, n, func(c Ctx) error {
1156 return c.SendStatus(203)
1157 })
1158
1159 req = httptest.NewRequest(MethodGet, "/test", http.NoBody)
1160
1161 resp, err = app.Test(req)
1162 require.NoError(t, err, "app.Test(req)")
1163 require.Equal(t, 203, resp.StatusCode, "Status code")
1164}
1165
1166func Test_App_Order(t *testing.T) {
1167 t.Parallel()

Callers

nothing calls this directly

Calls 8

methodIntMethod · 0.80
TestMethod · 0.80
NewFunction · 0.70
NextMethod · 0.65
UseMethod · 0.65
SendStatusMethod · 0.65
LenMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected