Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockHTTPRequest ¶
func MockHTTPRequest(handler func(c *gin.Context), method string, callback func(MockRequest))
MockHTTPRequest sets up a gin server with only the handler action to test it
Types ¶
type MockRequest ¶
type MockRequest interface {
MakeRequest(*RequestOptions) *httptest.ResponseRecorder
}
MockRequest is an interface for mocking requests
type RequestOptions ¶
type RequestOptions struct { Params map[string]string PostForm map[string]string Headers map[string]string }
RequestOptions hold test options to be set when making a request
func NewRequestOptions ¶
func NewRequestOptions() (o *RequestOptions)
NewRequestOptions returns a new RequestOptions
func (*RequestOptions) AddHeaders ¶
func (o *RequestOptions) AddHeaders(key string, value string)
AddHeaders adds a key, value to Headers
func (*RequestOptions) AddParams ¶
func (o *RequestOptions) AddParams(key string, value string)
AddParams adds a key, value to Params
func (*RequestOptions) AddPostForm ¶
func (o *RequestOptions) AddPostForm(key string, value string)
AddPostForm adds a key, value to PostForm
type TestRequest ¶
TestRequest holds info for mocking a request
func (*TestRequest) MakeRequest ¶
func (r *TestRequest) MakeRequest(o *RequestOptions) *httptest.ResponseRecorder
MakeRequest makes a http request and returns the ResponseRecorder
Click to show internal directories.
Click to hide internal directories.