Documentation
¶
Overview ¶
Package fixture defines the PERF-01 technical fixture: the same five Huma operations served by a standard Huma arm (humago on net/http) and by the adapter arm (humanirvana on a Nirvana router). Both arms share one Huma configuration, so they do equivalent work.
Index ¶
- Constants
- Variables
- func Config() huma.Config
- func GenerateBodies() map[string][]byte
- func NewHandler(arm string) (http.Handler, error)
- func WriteManifest(dir string) error
- type Case
- type Item
- type MiddlewareInput
- type MiddlewareOutput
- type NestedInput
- type NestedOutput
- type ParamsInput
- type ParamsOutput
- type Sink
- type SmallBody
- type SmallInput
- type SmallOutput
Constants ¶
const ( Native = "native" Adapter = "adapter" )
Arms under comparison.
const ProtocolRevision = 1
ProtocolRevision identifies the frozen fixture. Changing operations, payloads or expectations requires a new revision and a full re-run.
Variables ¶
var CaseIDs = []string{"P01", "P02", "P03", "P04", "P05"}
CaseIDs lists the request sets in protocol order.
Functions ¶
func Config ¶
Config is the Huma configuration both arms use. Schema link hooks are removed so response bodies do not depend on the listening address.
func GenerateBodies ¶
GenerateBodies builds the request bodies with their exact byte lengths.
func WriteManifest ¶
WriteManifest records the sha256 of every regular file in dir except the manifest itself.
Types ¶
type Case ¶
type Case struct {
ID string `json:"id"`
Method string `json:"method"`
Path string `json:"path"`
Header map[string]string `json:"header"`
BodyFile string `json:"body_file,omitempty"`
WantStatus int `json:"want_status"`
WantContentType string `json:"want_content_type"`
WantBody string `json:"want_body"`
Body []byte `json:"-"`
}
Case is one frozen PERF-01 request set: the exact request and the response every sample must return.
func (Case) NewRequest ¶
NewRequest builds the frozen request against base, e.g. "http://127.0.0.1:1".
type Item ¶
type Item struct {
ID int `json:"id" minimum:"0"`
Name string `json:"name" minLength:"1"`
Attrs struct {
Color string `json:"color" enum:"red,green,blue"`
Size int `json:"size" minimum:"0"`
} `json:"attrs"`
}
Item is one P03 entry.
type MiddlewareInput ¶
type MiddlewareInput struct {
RequestID string `header:"X-Request-ID"`
}
MiddlewareInput is P05.
type MiddlewareOutput ¶
type MiddlewareOutput struct {
Body struct {
Order []string `json:"order"`
Values string `json:"values"`
RequestID string `json:"request_id"`
}
}
MiddlewareOutput returns P05's middleware order and context values.
type NestedInput ¶
type NestedInput struct {
Body struct {
Items []Item `json:"items" minItems:"1" maxItems:"64"`
Padding string `json:"padding"`
}
}
NestedInput is P03.
type NestedOutput ¶
type NestedOutput struct {
Body struct {
Count int `json:"count"`
}
}
NestedOutput returns P03's item count.
type ParamsInput ¶
type ParamsInput struct {
ID int `path:"id"`
Count int `query:"count"`
Enabled bool `query:"enabled"`
Tenant string `header:"X-Tenant"`
}
ParamsInput is P01.
type ParamsOutput ¶
type ParamsOutput struct {
Body struct {
ID int `json:"id"`
Count int `json:"count"`
Enabled bool `json:"enabled"`
Tenant string `json:"tenant"`
}
}
ParamsOutput echoes P01's parsed values.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink is an in-memory log written by the P05 middleware; it does no I/O.
type SmallBody ¶
type SmallBody struct {
Quantity int `json:"quantity" minimum:"1"`
Padding string `json:"padding"`
}
SmallBody is the P02/P04 request body.
type SmallOutput ¶
type SmallOutput struct {
Body struct {
Accepted bool `json:"accepted"`
Quantity int `json:"quantity"`
}
}
SmallOutput confirms P02.