Documentation ¶
Index ¶
- type T
- func (t *T) AddCookies(c ...*http.Cookie) *T
- func (t *T) AddParams(k, v string) *T
- func (t *T) CheckBodyContains(want string) *T
- func (t *T) CheckCode(code int) *T
- func (t *T) CheckHeader(name, want string) *T
- func (t *T) Delete() *T
- func (t *T) Do() *T
- func (t *T) Get() *T
- func (t *T) GetBody() string
- func (t *T) GetCookies() []*http.Cookie
- func (t *T) GetResponseRecorder() *httptest.ResponseRecorder
- func (t *T) Head() *T
- func (t *T) Patch() *T
- func (t *T) Post() *T
- func (t *T) Put() *T
- func (t *T) SetBasicAuth(username, password string) *T
- func (t *T) SetContentType(contentType string) *T
- func (t *T) SetContentTypeFormUrlencoded() *T
- func (t *T) SetContentTypeMultipart() *T
- func (t *T) SetRequest(r *http.Request) *T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type T ¶
type T struct {
// contains filtered or unexported fields
}
T is a struct used of writing tests, contains request information.
func (*T) AddCookies ¶
AddCookies adds cookie(s) to the request.
func (*T) AddParams ¶
AddParams add parameters to request. In get request, the parameters are encoded in url.Values(url) In other requests, the parameters are encoded in request body.
func (*T) CheckBodyContains ¶
CheckBodyContains checks whether the body contains a certain string.
func (*T) CheckHeader ¶
CheckHeader checks whether the header value equals the expected.
func (*T) Do ¶
Do just make a request. CheckCode, CheckHeader, BodyContains and Body rely on Do. Just do it.
func (*T) GetCookies ¶
GetCookies returns the cookies that the test handler returns.
func (*T) GetResponseRecorder ¶
func (t *T) GetResponseRecorder() *httptest.ResponseRecorder
GetResponseRecorder returns the origin *httptest.ResponseRecorder
func (*T) Post ¶
Post means the method is post. Default ContentType of POST is application/x-www-form-urlencoded.
func (*T) SetBasicAuth ¶
SetBasicAuth set the request to use basic http auth.
func (*T) SetContentType ¶
SetContentType is used less except doing post. Default content-type of a post request is application/x-www-form-urlencoded.
func (*T) SetContentTypeFormUrlencoded ¶
SetContentTypeFormUrlencoded only works for post.
func (*T) SetContentTypeMultipart ¶
SetContentTypeMultipart only works for post.