(t *testing.T)
| 114 | } |
| 115 | |
| 116 | func TestTransformError(t *testing.T) { |
| 117 | config := huma.DefaultConfig("Test API", "1.0.0") |
| 118 | config.Transformers = []huma.Transformer{ |
| 119 | func(ctx huma.Context, status string, v any) (any, error) { |
| 120 | return nil, errors.New("whoops") |
| 121 | }, |
| 122 | } |
| 123 | _, api := humatest.New(t, config) |
| 124 | |
| 125 | req, _ := http.NewRequest("GET", "/", nil) |
| 126 | resp := httptest.NewRecorder() |
| 127 | ctx := humatest.NewContext(&huma.Operation{}, req, resp) |
| 128 | |
| 129 | require.Error(t, huma.WriteErr(api, ctx, 400, "bad request")) |
| 130 | } |
| 131 | |
| 132 | func TestErrorAs(t *testing.T) { |
| 133 | err := fmt.Errorf("wrapped: %w", huma.Error400BadRequest("test")) |
nothing calls this directly
no test coverage detected
searching dependent graphs…