(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestContextValue(t *testing.T) { |
| 73 | _, api := humatest.New(t) |
| 74 | |
| 75 | api.UseMiddleware(func(ctx huma.Context, next func(huma.Context)) { |
| 76 | // Make an updated context available to the handler. |
| 77 | ctx = huma.WithValue(ctx, "foo", "bar") |
| 78 | next(ctx) |
| 79 | assert.Equal(t, http.StatusNoContent, ctx.Status()) |
| 80 | }) |
| 81 | |
| 82 | // Register a simple hello world operation in the API. |
| 83 | huma.Get(api, "/test", func(ctx context.Context, input *struct{}) (*struct{}, error) { |
| 84 | assert.Equal(t, "bar", ctx.Value("foo")) |
| 85 | return nil, nil |
| 86 | }) |
| 87 | |
| 88 | resp := api.Get("/test") |
| 89 | assert.Equal(t, http.StatusNoContent, resp.Code) |
| 90 | } |
| 91 | |
| 92 | func TestResponseContentTypeWithExtensions(t *testing.T) { |
| 93 | _, api := humatest.New(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…