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

Function Test_App_Order

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

Source from the content-addressed store, hash-verified

1164}
1165
1166func Test_App_Order(t *testing.T) {
1167 t.Parallel()
1168 app := New()
1169
1170 app.Get("/test", func(c Ctx) error {
1171 _, err := c.WriteString("1")
1172 require.NoError(t, err)
1173 return c.Next()
1174 })
1175
1176 app.All("/test", func(c Ctx) error {
1177 _, err := c.WriteString("2")
1178 require.NoError(t, err)
1179
1180 return c.Next()
1181 })
1182
1183 app.Use(func(c Ctx) error {
1184 _, err := c.WriteString("3")
1185 require.NoError(t, err)
1186
1187 return c.SendStatus(StatusOK)
1188 })
1189
1190 req := httptest.NewRequest(MethodGet, "/test", http.NoBody)
1191
1192 resp, err := app.Test(req)
1193 require.NoError(t, err, "app.Test(req)")
1194 require.Equal(t, 200, resp.StatusCode, "Status code")
1195
1196 body, err := io.ReadAll(resp.Body)
1197 require.NoError(t, err)
1198 require.Equal(t, "123", string(body))
1199}
1200
1201func Test_App_AutoHead_Compliance(t *testing.T) {
1202 t.Parallel()

Callers

nothing calls this directly

Calls 8

TestMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
WriteStringMethod · 0.65
NextMethod · 0.65
AllMethod · 0.65
UseMethod · 0.65
SendStatusMethod · 0.65

Tested by

no test coverage detected