Documentation ¶
Index ¶
- type Client
- func (cl *Client) Delete(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
- func (cl *Client) Do(c context.Context, req *fetcher.Request) (*fetcher.Response, error)
- func (cl *Client) ExpectRequest(c context.Context, method, url string, opts ...ExpectedRequestOption) error
- func (cl *Client) Get(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
- func (cl *Client) Head(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
- func (cl *Client) NewRequest(c context.Context, method, url string, opts ...fetcher.RequestOption) (*fetcher.Request, error)
- func (cl *Client) Patch(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
- func (cl *Client) Post(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
- func (cl *Client) Put(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
- func (cl *Client) UnmetExpectations() []*ExpectedRequest
- type ClientOption
- type ExpectedRequest
- type ExpectedRequestOption
- func WithRequestOptions(opts ...fetcher.RequestOption) ExpectedRequestOption
- func WithResponseBodyBytes(b []byte) ExpectedRequestOption
- func WithResponseBodyReader(r io.Reader) ExpectedRequestOption
- func WithResponseError(err error) ExpectedRequestOption
- func WithResponseHeader(key, value string) ExpectedRequestOption
- func WithResponseStatus(status string) ExpectedRequestOption
- func WithResponseStatusCode(code int) ExpectedRequestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to mock the fetcher.Client
func NewClient ¶
func NewClient(c context.Context, opts ...ClientOption) (*Client, error)
NewClient returns a new Client with the given options executed
func (*Client) Delete ¶
func (cl *Client) Delete(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
Delete is a helper func for Do, setting the Method internally
func (*Client) Do ¶
Do mocks the execution of a request by matching it up with an expectedRequest If no matching expectedRequests are found, fetchermock will exit with errors
func (*Client) ExpectRequest ¶
func (cl *Client) ExpectRequest(c context.Context, method, url string, opts ...ExpectedRequestOption) error
ExpectRequest creates an ExpectedRequest and adds it to the cl.expectedRequests
func (*Client) Get ¶
func (cl *Client) Get(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
Get is a helper func for Do, setting the Method internally
func (*Client) Head ¶
func (cl *Client) Head(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
Head is a helper func for Do, setting the Method internally
func (*Client) NewRequest ¶
func (cl *Client) NewRequest(c context.Context, method, url string, opts ...fetcher.RequestOption) (*fetcher.Request, error)
NewRequest returns a new Request with the given method/url and options executed
func (*Client) Patch ¶
func (cl *Client) Patch(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
Patch is a helper func for Do, setting the Method internally
func (*Client) Post ¶
func (cl *Client) Post(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
Post is a helper func for Do, setting the Method internally
func (*Client) Put ¶
func (cl *Client) Put(c context.Context, url string, opts ...fetcher.RequestOption) (*fetcher.Response, error)
Put is a helper func for Do, setting the Method internally
func (*Client) UnmetExpectations ¶
func (cl *Client) UnmetExpectations() []*ExpectedRequest
UnmetExpectations returns the slice of ExpectedRequests that were not met in execution
type ClientOption ¶
ClientOption is a func to configure optional Client settings
func WithExpectationsInOrder ¶
func WithExpectationsInOrder(inOrder bool) ClientOption
WithExpectationsInOrder sets the cl.withExpectationsInOrder value
func WithFetcherClientOptions ¶
func WithFetcherClientOptions(opts ...fetcher.ClientOption) ClientOption
WithFetcherClientOptions sets the cl.withFetcherClientOptions value
type ExpectedRequest ¶
type ExpectedRequest struct {
// contains filtered or unexported fields
}
ExpectedRequest contains the info for a Request to expect in execution
type ExpectedRequestOption ¶
type ExpectedRequestOption func(c context.Context, expReq *ExpectedRequest) error
ExpectedRequestOption is a func to configure optional settings for an ExpectedRequest
func WithRequestOptions ¶
func WithRequestOptions(opts ...fetcher.RequestOption) ExpectedRequestOption
WithRequestOptions adds all the given fetcher.RequestOptions to the requestOptions in the ExpectedRequest
func WithResponseBodyBytes ¶
func WithResponseBodyBytes(b []byte) ExpectedRequestOption
WithResponseBodyBytes sets the responseBodyBytes in the ExpectedRequest
func WithResponseBodyReader ¶
func WithResponseBodyReader(r io.Reader) ExpectedRequestOption
WithResponseBodyReader sets the responseBodyReader in the ExpectedRequest
func WithResponseError ¶
func WithResponseError(err error) ExpectedRequestOption
WithResponseError sets the ResponseError in the ExpectedRequest
func WithResponseHeader ¶
func WithResponseHeader(key, value string) ExpectedRequestOption
WithResponseHeader sets the key/value in the responseHeader in the ExpectedRequest
func WithResponseStatus ¶
func WithResponseStatus(status string) ExpectedRequestOption
WithResponseStatus sets the responseStatus in the ExpectedRequest
func WithResponseStatusCode ¶
func WithResponseStatusCode(code int) ExpectedRequestOption
WithResponseStatusCode sets the responseStatusCode in the ExpectedRequest