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

Function Test_Bind_CustomBinder_Source

bind_test.go:2266–2286  ·  view source on GitHub ↗

go test -run Test_Bind_CustomBinder_Source

(t *testing.T)

Source from the content-addressed store, hash-verified

2264
2265// go test -run Test_Bind_CustomBinder_Source
2266func Test_Bind_CustomBinder_Source(t *testing.T) {
2267 t.Parallel()
2268
2269 app := New()
2270 c := app.AcquireCtx(&fasthttp.RequestCtx{})
2271 t.Cleanup(func() { app.ReleaseCtx(c) })
2272
2273 app.RegisterCustomBinder(&customBinder{})
2274
2275 type Demo struct {
2276 Name string `json:"name"`
2277 }
2278 c.Request().SetBody([]byte(`{invalid json`))
2279 c.Request().Header.SetContentLength(14)
2280
2281 err := c.Bind().Custom("custom", new(Demo))
2282 require.Error(t, err)
2283 var be *BindError
2284 require.ErrorAs(t, err, &be)
2285 require.Equal(t, "custom", be.Source)
2286}
2287
2288// go test -run Test_Bind_CustomBinder_Validation
2289func Test_Bind_CustomBinder_Validation(t *testing.T) {

Callers

nothing calls this directly

Calls 8

AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
RegisterCustomBinderMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
BindMethod · 0.65
ErrorMethod · 0.65
CustomMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…