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

Function Test_App_UseMountedErrorHandlerRootLevel

mount_test.go:358–375  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

356}
357
358func Test_App_UseMountedErrorHandlerRootLevel(t *testing.T) {
359 t.Parallel()
360 app := New()
361
362 fiber := New(Config{
363 ErrorHandler: func(c Ctx, _ error) error {
364 return c.Status(500).SendString("hi, i'm a custom error")
365 },
366 })
367 fiber.Get("/api", func(_ Ctx) error {
368 return errors.New("something happened")
369 })
370
371 app.Use("/", fiber)
372
373 resp, err := app.Test(httptest.NewRequest(MethodGet, "/api", http.NoBody))
374 testErrorResponse(t, err, resp, "hi, i'm a custom error")
375}
376
377func Test_App_UseMountedErrorHandlerForBestPrefixMatch(t *testing.T) {
378 t.Parallel()

Callers

nothing calls this directly

Calls 8

testErrorResponseFunction · 0.85
TestMethod · 0.80
NewFunction · 0.70
SendStringMethod · 0.65
StatusMethod · 0.65
GetMethod · 0.65
NewMethod · 0.65
UseMethod · 0.65

Tested by

no test coverage detected