Documentation
¶
Overview ¶
Package testserver is the "Bookstore" API used by the component tests of apitest. Its spec is testdata/bookstore.yaml. Each switch in Faults builds in exactly one kind of error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Faults ¶
type Faults struct {
WrongStatus bool // POST /authors answers 200 instead of 201
UndocumentedStatus bool // GET /books/{id} answers 202
SchemaViolation bool // GET /books/{id} returns authorId as a string
ExampleMismatch bool // POST /authors returns a different name than it stores
Slow bool // GET /authors answers after 30 s (or when the request ends)
DropOnUpdate bool // PUT /books/{id} answers 200 but does not store the title
DeleteNoop bool // DELETE /reviews/{id} answers 204 but does not delete
FailCreateAuthor bool // POST /authors with a valid body answers 500
DropShelfName bool // PUT /shelves/{code} stores the new code but not the name
IgnoreAuth bool // requests without token (or api_key) are accepted
IgnoreSignature bool // any bearer token is accepted, also manipulated ones
IgnoreRoles bool // the reader token may write
// AsyncUpdate makes PUT /authors/{id} visible only after this many GETs
// of the author (eventual consistency, FR-VERIFY-06); 0 applies at once.
AsyncUpdate int
}
Faults switch on deliberate errors.
type Server ¶
type Server struct {
Tokens []string // accepted bearer tokens with full rights
Readers []string // accepted bearer tokens that may only read (403 on writes)
APIKey string // expected api_key query parameter
Faults Faults
// contains filtered or unexported fields
}
Server is the Bookstore API. It is an http.Handler serving under /v1.