| 3494 | } |
| 3495 | |
| 3496 | func 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 | |
| 3514 | type ResolverCalls struct { |
| 3515 | Calls int |