Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expectation ¶
type Expectation interface {
// Check will give the expectation the incoming request to be validated
Check(req *http.Request)
// Met will check if the check has passed
Met() bool
// Message is the msg passed to error.New if the expectation wasn't met
Message() string
}
Expectation is an interface for an expectation check for the request that will be made
type ExpectedBody ¶
type ExpectedBody struct {
// contains filtered or unexported fields
}
ExpectedBody verifies that the request body matches the expected body
func (*ExpectedBody) Check ¶
func (e *ExpectedBody) Check(req *http.Request)
Check will verify the body in the request matches the expected body
func (*ExpectedBody) Message ¶
func (e *ExpectedBody) Message() string
Message returns the error message or "" if none
func (*ExpectedBody) Met ¶
func (e *ExpectedBody) Met() bool
Met returns whether or not the expectation has been met
type ExpectedHeader ¶
type ExpectedHeader struct {
// contains filtered or unexported fields
}
ExpectedHeader will verify the sent header matches the expected header
func (*ExpectedHeader) Check ¶
func (e *ExpectedHeader) Check(req *http.Request)
Check will verify the headers match the expected
func (*ExpectedHeader) Message ¶
func (e *ExpectedHeader) Message() string
Message returns the error message or "" if none
func (*ExpectedHeader) Met ¶
func (e *ExpectedHeader) Met() bool
Met returns whether or not the expectations were met
type ExpectedMethod ¶
type ExpectedMethod struct {
// contains filtered or unexported fields
}
ExpectedMethod will verify that the request method matches the expected method
func (*ExpectedMethod) Check ¶
func (m *ExpectedMethod) Check(req *http.Request)
Check will verify the *http.Request method matches the expected method
func (*ExpectedMethod) Message ¶
func (m *ExpectedMethod) Message() string
Message returns the error message or "" if none
type Mock ¶
type Mock interface {
// ExpectMethod sets the method expected on the incoming request
ExpectMethod(method string) Mock
// ExpectBody sets the body expected on the incoming request
ExpectBody(body string) Mock
// ExpectHeader sets the expected headers on the incoming request
ExpectHeader(header http.Header) Mock
// Expectation allows for any custom expectation that follows the Expectation interface
Expectation(exp Expectation) Mock
// ExpectationsMet will return an error if expectations weren't met
ExpectationsMet() error
// ReturnStatus will set the status on returned http.Response
ReturnStatus(status int) Mock
// ReturnBody will set the body on the returned http.Response to the given io.Reader
ReturnBody(body io.Reader) Mock
// ReturnHeader will set the headers on the returned http.Response to the given headers
ReturnHeader(header http.Header) Mock
// ReturnError will return an error instead of a response object
ReturnError(err error) Mock
}
Mock interface serves to create expectations for any kind of http.Client action in order to mock and test real http.Client behavior.
type SetBody ¶
type SetBody struct {
// contains filtered or unexported fields
}
SetBody implements the Setter interface and sets the status code
type SetHeader ¶
type SetHeader struct {
// contains filtered or unexported fields
}
SetHeader implements the Setter interface and sets the response headers
type SetStatusCode ¶
type SetStatusCode struct {
// contains filtered or unexported fields
}
SetStatusCode implements the Setter interface and sets the status code
func (*SetStatusCode) Set ¶
func (s *SetStatusCode) Set(resp *http.Response)
Set will set the response status code with the returning status