Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client asserts that requests made match the expected ones.
type ErrorReader ¶
type ErrorReader struct {
Error error
}
ErrorReader is an io.Reader that always returns an error. Useful for testing network errors when reading HTTP response bodies.
type Request ¶
type Request struct {
// Expectations set the expectations on the request, which are asserted when
// the request is made.
Expectations RequestExpectations
// Response describes the response to the request.
Response Response
}
Request describes a request made to and handled by Client.
type RequestExpectations ¶
type RequestExpectations struct {
URL string
Header http.Header
// Body is the response's body. Defaults to being empty.
// Available types, in order of precedence:
// - string: path to file
// - string: verbatim string
// - []byte
// - io.Reader
Body any
}
RequestExpectations describes the expectations on the request.
type Response ¶
type Response struct {
// Status defaults to the status text of StatusCode.
Status string
// StatusCode defaults to 200.
StatusCode int
// Header defaults to an empty header.
Header http.Header
// Body is the response's body. Defaults to being empty.
// Available types, in order of precedence:
// - string: path to file
// - string: verbatim string
// - []byte
// - io.ReadCloser
// - io.Reader
// - error: alias for ErrorReader{Error: err}
Body any
// Error is the response error, if any.
Error error
}
Response describes a response to a request made to Client.
Click to show internal directories.
Click to hide internal directories.