Documentation ¶
Overview ¶
Package mocks provides mocks and helpers used in testing.
Index ¶
- Constants
- func NewRequest() *http.Request
- func NewRequestForURL(u string) *http.Request
- func NewRequestWithContent(c string) *http.Request
- func NewResponse() *http.Response
- func NewResponseWithContent(c string) *http.Response
- func NewResponseWithStatus(s string, c int) *http.Response
- func SetAcceptedHeaders(resp *http.Response)
- func SetLocationHeader(resp *http.Response, location string)
- func SetResponseHeader(resp *http.Response, h string, v string)
- func SetResponseHeaderValues(resp *http.Response, h string, values []string)
- func SetRetryHeader(resp *http.Response, delay time.Duration)
- type Body
- type Sender
- func (c *Sender) Attempts() int
- func (c *Sender) ClearError()
- func (c *Sender) Do(r *http.Request) (*http.Response, error)
- func (c *Sender) EmitContent(s string)
- func (c *Sender) EmitErrors(emit int)
- func (c *Sender) EmitStatus(status string, code int)
- func (c *Sender) ReuseResponse(reuseResponse bool)
- func (c *Sender) SetError(err error)
- func (c *Sender) SetPollAttempts(pa int)
- func (c *Sender) SetResponse(resp *http.Response)
- type T
Constants ¶
const ( // TestDelay is the Retry-After delay used in tests. TestDelay = 0 * time.Second // TestHeader is the header used in tests. TestHeader = "x-test-header" // TestURL is the URL used in tests. TestURL = "https://microsoft.com/a/b/c/" )
Variables ¶
This section is empty.
Functions ¶
func NewRequestForURL ¶
NewRequestForURL instantiates a new request using the passed URL.
func NewRequestWithContent ¶
NewRequestWithContent instantiates a new request using the passed string for the body content.
func NewResponseWithContent ¶
NewResponseWithContent instantiates a new response with the passed string as the body content.
func NewResponseWithStatus ¶
NewResponseWithStatus instantiates a new response using the passed string and integer as the status and status code.
func SetAcceptedHeaders ¶
SetAcceptedHeaders adds the headers usually associated with a 202 Accepted response.
func SetLocationHeader ¶
SetLocationHeader adds the Location header.
func SetResponseHeader ¶
SetResponseHeader adds a header to the passed response.
func SetResponseHeaderValues ¶
SetResponseHeaderValues adds a header containing all the passed string values.
Types ¶
type Body ¶
type Body struct {
// contains filtered or unexported fields
}
Body implements acceptable body over a string.
func (*Body) CloseAttempts ¶
CloseAttempts returns the number of times Close was called.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender implements a simple null sender.
func (*Sender) Do ¶
Do accepts the passed request and, based on settings, emits a response and possible error.
func (*Sender) EmitContent ¶
EmitContent sets the content to be returned by Do in the response body.
func (*Sender) EmitErrors ¶
EmitErrors sets the number times Do should emit an error.
func (*Sender) EmitStatus ¶
EmitStatus sets the status of the response Do emits.
func (*Sender) ReuseResponse ¶
ReuseResponse sets if the just one response object should be reused by all calls to Do.
func (*Sender) SetPollAttempts ¶
SetPollAttempts sets the number of times the returned response emits the default polling status code (i.e., 202 Accepted).
func (*Sender) SetResponse ¶
SetResponse sets the response from Do.