Documentation ¶
Index ¶
- func DeActivate()
- func Register(method string, request string)
- func RegisterWithCode(method string, request string, code int)
- func RegisterWithResponder(method string, request string, cb func(req *http.Request) (int, string))
- func RegisterWithResponderBody(method string, request string, code int, ...)
- func RegisterWithResponse(method string, request string, code int, responseFile string)
- func RegisterWithResponseBody(method string, request string, code int, responseBody string)
- func RegisterWithResponseBytes(method string, request string, code int, responseBytes []byte)
- type HTTPMock
- func (mock *HTTPMock) Register(method string, request string)
- func (mock *HTTPMock) RegisterWithCode(method string, request string, code int)
- func (mock *HTTPMock) RegisterWithResponder(method string, request string, cb func(req *http.Request) (int, string))
- func (mock *HTTPMock) RegisterWithResponderBody(method string, request string, cb func(req *http.Request) (int, string))
- func (mock *HTTPMock) RegisterWithResponse(method string, request string, code int, responseFile string)
- func (mock *HTTPMock) RegisterWithResponseBody(method string, request string, code int, responseBody string)
- func (mock *HTTPMock) RegisterWithResponseBytes(method string, request string, code int, responseBytes []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterWithCode ¶
RegisterWithCode defers to the default HTTPMock's RegisterWithCode or errors if no default defined.
func RegisterWithResponder ¶
RegisterWithResponder defers to the default HTTPMock's RegisterWithResponder or errors if no default defined.
func RegisterWithResponderBody ¶
func RegisterWithResponderBody(method string, request string, code int, cb func(req *http.Request) (int, string))
RegisterWithResponderBody defers to the default HTTPMock's RegisterWithResponderBody or errors if no default defined.
func RegisterWithResponse ¶
RegisterWithResponse defers to the default HTTPMock's RegisterWithResponse or errors if no default defined.
func RegisterWithResponseBody ¶
RegisterWithResponseBody defers to the default HTTPMock's RegisterWithResponseBody or errors if no default defined.
Types ¶
type HTTPMock ¶
type HTTPMock struct {
// contains filtered or unexported fields
}
HTTPMock encapsulate the functionality for mocking requests to a specific base-url.
func Activate ¶
Activate an and return an *HTTPMock instance. If none yet activated, then the first becomes the default HTTPMock; which means you can just call package funcs to use it.
func (*HTTPMock) Register ¶
Register registers a httpmock for the given request (the response file is based on the request)
func (*HTTPMock) RegisterWithCode ¶
RegisterWithCode is the same as Register but it allows specifying a code
func (*HTTPMock) RegisterWithResponder ¶
func (mock *HTTPMock) RegisterWithResponder(method string, request string, cb func(req *http.Request) (int, string))
RegisterWithResponder register a httpmock with a custom responder
func (*HTTPMock) RegisterWithResponderBody ¶
func (mock *HTTPMock) RegisterWithResponderBody(method string, request string, cb func(req *http.Request) (int, string))
RegisterWithResponderBody register a httpmock with a custom responder that returns the response body
func (*HTTPMock) RegisterWithResponse ¶
func (mock *HTTPMock) RegisterWithResponse(method string, request string, code int, responseFile string)
RegisterWithResponse is the same as RegisterWithCode but it allows specifying a response file