Documentation
¶
Overview ¶
Package apitest holds a server to the API's description, api.OpenAPI, in tests. Handler wraps a server's handler, and checks what passes through it:
- every answer, in strict mode, so a member, a status or a header the description does not name fails, as does one it requires and the answer lacks (a header it does not name is looked for only once every header it names is right: the validator checks that last);
- every request: one the description refuses must not be answered 2xx;
- a route the description lacks gets the router's plain 404 or 405;
- every error's code counts (protocol.Problem.CodeAt): one the description knows, under its own status, beside its own type;
- an answer in gzip is one to a request that takes gzip, and is checked as the JSON beneath; the description says which answers may be.
The server and the Go client share protocol's structs, so a member that drifts from PROTOCOL.md passes every test the two run together. This is what fails then.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler returns h, with each request and answer checked against the description and every disagreement reported to t.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.