Documentation ¶
Index ¶
- type FakeClient
- func (c *FakeClient) Do(req *http.Request) (*http.Response, error)
- func (c *FakeClient) GetRequests() []RequestCopy
- func (c *FakeClient) Send(req *api.Request) (*http.Response, error)
- func (c *FakeClient) SetResponse(resp *TestResponse, err error)
- func (c *FakeClient) WaitUntilRequestCount(t *testing.T, n int, timeout time.Duration)
- type RequestCopy
- type TestResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeClient ¶
FakeClient is a fake api.Client meant for testing.
It allows stubbing out responses and records all requests sent.
Since the api.Client contract is very simple, it's not useful to use a real object in tests.
func NewFakeClient ¶
func NewFakeClient(baseURLString string) *FakeClient
func (*FakeClient) GetRequests ¶
func (c *FakeClient) GetRequests() []RequestCopy
GetRequests returns all requests made to the fake client.
func (*FakeClient) SetResponse ¶
func (c *FakeClient) SetResponse(resp *TestResponse, err error)
SetResponse configures the client's response to all requests.
func (*FakeClient) WaitUntilRequestCount ¶
WaitUntilRequestCount blocks until len(GetRequests()) >= n.
type RequestCopy ¶
type TestResponse ¶
type TestResponse struct {
StatusCode int
}
TestResponse is an easy-to-use http.Response for tests.
Click to show internal directories.
Click to hide internal directories.