Documentation
¶
Overview ¶
Package httpwiretest checks an app's httpwire API from its handler tests: every answer against the row's declared shapes in the document the API runs with, and each owner package's sentinels against its code table.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contract ¶
Contract serves each case through api and fails t, naming the row, on any answer outside the row's shapes in the OpenAPI document api was built with: an undeclared success status, a body that does not decode strictly into the status's Response type or breaks its schema, a Raw answer of another media type, an error that is not an envelope of a code in the row's union at the catalog's status, and no Wire-Version of this API or valid X-Request-Id. A HEAD answer's body is not read. A case naming no row, a Stream row, or a request the API routes to another row fails.
func Sentinels ¶
Sentinels fails t unless the exported Err* vars that the package in the working directory declares (its non-test files for this build, as go test sets the directory) are exactly the keys of owner.Sentinels, and owner passes every owner check New makes but the catalog's, so a sentinel with no code fails the owner package's own test.
Types ¶
type Case ¶
type Case struct {
// Request is built by the test, carrying its own principal.
Request *http.Request
// Row is a row name of the API's table, mount rows included.
Row string
}
Case is one request Contract serves.
type Option ¶
type Option func(*options)
Option configures Contract.
func WithSameShape ¶
WithSameShape serves every case of a read row with Changes and no Personal as both principals, and fails the row when the guard gives them two shapes or their answers differ as JSON values (a List answer's cursors left out). Every such row then needs a case. It may be passed more than once; each pair runs over every such case.