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

Function TestNewAPI

humatest/humatest_test.go:135–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

133}
134
135func TestNewAPI(t *testing.T) {
136 var api huma.API
137 _, api = New(t, huma.DefaultConfig("Test", "1.0.0"))
138
139 // Should be able to wrap and call utility methods.
140 wrapped := Wrap(t, api)
141 wrapped.Get("/")
142 wrapped.Post("/")
143 wrapped.Put("/")
144 wrapped.Patch("/")
145 wrapped.Delete("/")
146
147 assert.Panics(t, func() {
148 // Invalid param type (only string headers and io.Reader bodies are allowed)
149 wrapped.Post("/", 1234)
150 })
151}
152
153func TestDumpBodyError(t *testing.T) {
154 req := httptest.NewRequest(http.MethodGet, "http://example.com/foo?bar=baz", nil)

Callers

nothing calls this directly

Calls 7

WrapFunction · 0.85
NewFunction · 0.70
GetMethod · 0.65
PostMethod · 0.65
PutMethod · 0.65
PatchMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…