Documentation ¶
Index ¶
- type TestService
- func (s *TestService) AssertCalled()
- func (s *TestService) AssertNotCalled()
- func (s *TestService) AssertReceivedAs(v interface{})
- func (s *TestService) AssertReceivedBasicAuth(user, pass string)
- func (s *TestService) AssertReceivedBody(body []byte)
- func (s *TestService) AssertReceivedHeader(name string, value string)
- func (s *TestService) AssertReceivedJSON(expected string)
- func (s *TestService) AssertReceivedMethod(method string)
- func (s *TestService) AssertReceivedParam(name string, value string)
- func (s *TestService) AssertReceivedPath(path string)
- func (s *TestService) SetResponseBody(b interface{})
- func (s *TestService) SetResponseCode(code int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestService ¶
TestService is a helpful test utility that allows tests to call a real HTTP service during test runs.
func NewTestService ¶
func NewTestService(t *testing.T) *TestService
NewTestService will return a test service configured for the provided test state.
This init also handles the starting and cleanup of the test service once the test is completed.
func (*TestService) AssertCalled ¶
func (s *TestService) AssertCalled()
AssertCalled allows callers to assert that the service has received a request.
func (*TestService) AssertNotCalled ¶
func (s *TestService) AssertNotCalled()
AssertNotCalled allows callers to assert that the service has not received a request.
func (*TestService) AssertReceivedAs ¶
func (s *TestService) AssertReceivedAs(v interface{})
AssertReceivedAs allows callers to assert that the last request received could be unmarshalled as the value provided.
func (*TestService) AssertReceivedBasicAuth ¶
func (s *TestService) AssertReceivedBasicAuth(user, pass string)
AssertReceivedBasicAuth allows callers to assert that the last request received was authenticated with the provided values.
func (*TestService) AssertReceivedBody ¶
func (s *TestService) AssertReceivedBody(body []byte)
AssertReceivedBody allows callers to assert that the last request received matches the body provided.
func (*TestService) AssertReceivedHeader ¶
func (s *TestService) AssertReceivedHeader(name string, value string)
AssertReceivedHeader allows callers to assert that the last request received contained the header provided.
func (*TestService) AssertReceivedJSON ¶
func (s *TestService) AssertReceivedJSON(expected string)
AssertReceivedBody allows callers to assert that the last request received matches the JSON string provided.
func (*TestService) AssertReceivedMethod ¶
func (s *TestService) AssertReceivedMethod(method string)
AssertReceivedBody allows callers to assert that the last request received matches the HTTP Method provided.
func (*TestService) AssertReceivedParam ¶
func (s *TestService) AssertReceivedParam(name string, value string)
AssertReceivedHeader allows callers to assert that the last request received contained the query param provided.
func (*TestService) AssertReceivedPath ¶
func (s *TestService) AssertReceivedPath(path string)
AssertReceivedPath allows callers to assert that the last request received was for the path provided.
func (*TestService) SetResponseBody ¶
func (s *TestService) SetResponseBody(b interface{})
SetResponseBody will set the provided value as the response body for any requests received by the service.
The method accepts bytes and strings which will be returned directly from the service. Passing structs or other types will result in the response being the JSON encoding of those values.
func (*TestService) SetResponseCode ¶
func (s *TestService) SetResponseCode(code int)
SetResponseCode will set the provided value as the status code the service will return for any requests received by the service.