go test -run Test_Bind_CustomBinder_Source
(t *testing.T)
| 2264 | |
| 2265 | // go test -run Test_Bind_CustomBinder_Source |
| 2266 | func 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 |
| 2289 | func Test_Bind_CustomBinder_Validation(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…