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

Function Test_App_ErrorHandler_GroupMountRootLevel

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

Source from the content-addressed store, hash-verified

280}
281
282func Test_App_ErrorHandler_GroupMountRootLevel(t *testing.T) {
283 t.Parallel()
284 micro := New(Config{
285 ErrorHandler: func(c Ctx, err error) error {
286 require.Equal(t, "0: GET error", err.Error())
287 return c.Status(500).SendString("1: custom error")
288 },
289 })
290 micro.Get("/john/doe", func(_ Ctx) error {
291 return errors.New("0: GET error")
292 })
293
294 app := New()
295 v1 := app.Group("/v1")
296 v1.Use("/", micro)
297
298 resp, err := app.Test(httptest.NewRequest(MethodGet, "/v1/john/doe", http.NoBody))
299 testErrorResponse(t, err, resp, "1: custom error")
300}
301
302// go test -run Test_App_Group_Mount
303func Test_App_Group_Mount(t *testing.T) {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected