MCPcopy
hub / github.com/danielgtaylor/huma / TestResolverCustomStatus

Function TestResolverCustomStatus

huma_test.go:3496–3512  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3494}
3495
3496func TestResolverCustomStatus(t *testing.T) {
3497 r, app := humatest.New(t, huma.DefaultConfig("Test API", "1.0.0"))
3498 huma.Register(app, huma.Operation{
3499 OperationID: "test",
3500 Method: http.MethodPut,
3501 Path: "/test",
3502 }, func(ctx context.Context, input *ResolverCustomStatus) (*struct{}, error) {
3503 return nil, nil
3504 })
3505
3506 req, _ := http.NewRequest(http.MethodPut, "/test", strings.NewReader(`{}`))
3507 req.Header.Set("Content-Type", "application/json")
3508 w := httptest.NewRecorder()
3509 r.ServeHTTP(w, req)
3510 assert.Equal(t, http.StatusForbidden, w.Code, w.Body.String())
3511 assert.Contains(t, w.Body.String(), "nope")
3512}
3513
3514type ResolverCalls struct {
3515 Calls int

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
ServeHTTPMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…