Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPTestCaller ¶
type HTTPTestCaller struct {
// contains filtered or unexported fields
}
HTTPTestCaller is a wrapper for testing HTTP handler, it will pass the request to the handler and record the response using httptest.ResponseRecorder. If the response type is set, it will try to unmarshal the response body to the type
func Call ¶
func Call(handler http.Handler) *HTTPTestCaller
Call creates the caller with handler specified, use this function to start the caller
func (*HTTPTestCaller) Execute ¶
func (caller *HTTPTestCaller) Execute() (*httptest.ResponseRecorder, interface{}, error)
Execute calls the handler with the request and records the response in httptest.ResponseRecorder. If the expected response type exists, it will try to unmarshal the response body to the type
func (*HTTPTestCaller) Read ¶
func (caller *HTTPTestCaller) Read(response interface{}) *HTTPTestCaller
Read specifies the expected type of response returned by the handler being tested
func (*HTTPTestCaller) To ¶
func (caller *HTTPTestCaller) To(request *http.Request, _ ...interface{}) *HTTPTestCaller
To receives a request to be sent to the handler. The second parameter is a convenience if you want to pass directly from http.NewRequest() or gorequest.MakeRequest()