Documentation ¶
Index ¶
- Constants
- type Checker
- type Option
- type Tester
- func (tt *Tester) Cb(callback func(*http.Response))
- func (tt *Tester) Check() *Tester
- func (tt *Tester) ContainsBody(segment []byte) *Tester
- func (tt *Tester) ContainsString(substr string) *Tester
- func (tt *Tester) HasBody(body []byte) *Tester
- func (tt *Tester) HasCookie(key, expectedValue string) *Tester
- func (tt *Tester) HasHeader(key, expectedValue string) *Tester
- func (tt *Tester) HasHeaders(headers map[string]string) *Tester
- func (tt *Tester) HasJSON(value interface{}) *Tester
- func (tt *Tester) HasJson(value interface{}) *Tester
- func (tt *Tester) HasStatus(status int) *Tester
- func (tt *Tester) HasString(body string) *Tester
- func (tt *Tester) HasXML(value interface{}) *Tester
- func (tt *Tester) HasXml(value interface{}) *Tester
- func (tt *Tester) NotContainsBody(segment []byte) *Tester
- func (tt *Tester) NotContainsString(substr string) *Tester
- func (tt *Tester) WithBasicAuth(user, pass string) *Tester
- func (tt *Tester) WithBearerAuth(token string) *Tester
- func (tt *Tester) WithBody(body []byte) *Tester
- func (tt *Tester) WithCookie(key, value string) *Tester
- func (tt *Tester) WithHeader(key, value string) *Tester
- func (tt *Tester) WithHeaders(headers map[string]string) *Tester
- func (tt *Tester) WithHostHeader(value string) *Tester
- func (tt *Tester) WithJSON(value interface{}) *Tester
- func (tt *Tester) WithJson(value interface{}) *Tester
- func (tt *Tester) WithString(body string) *Tester
- func (tt *Tester) WithXML(value interface{}) *Tester
- func (tt *Tester) WithXml(value interface{}) *Tester
Constants ¶
const ( // DefaultClientTimeout is the default timeout for requests made by checker. DefaultClientTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker represents the HTTP checker without testing.T.
func (*Checker) PersistCookie ¶
PersistCookie - enables a cookie to be preserved between requests
func (*Checker) Test ¶
Test - Prepare for testing some part of code which lives on provided path and method.
func (*Checker) TestRequest ¶
TestRequest - If you want to provide you custom http.Request instance, you can do it using this method In this case internal http.Request instance won't be created, and passed instance will be used for making request
func (*Checker) UnpersistCookie ¶
UnpersistCookie - the specified cookie will not be preserved during requests anymore
type Option ¶
type Option func(*Checker)
Option represents the option for the checker.
func CheckRedirect ¶ added in v1.4.0
CheckRedirect sets the policy of redirection to the HTTP client.
func ClientTimeout ¶
ClientTimeout sets the client timeout.
func NoRedirect ¶ added in v1.4.0
func NoRedirect() Option
NoRedirect is the alias of the following:
CheckRedirect(func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse })
Client returns ErrUseLastResponse, the next request is not sent and the most recent response is returned with its body unclosed.
type Tester ¶
type Tester struct { *Checker // contains filtered or unexported fields }
Tester represents the HTTP tester having testing.T.
func (*Tester) Check ¶
Check - Will make request to built request object. After request is made, it will save response object for future assertions Responsibility of this method is also to start and stop HTTP server
func (*Tester) ContainsBody ¶
ContainsBody checks if the body contains provided [] byte data.
func (*Tester) ContainsString ¶
ContainsString converts the response to a string type and then checks it containing the given string.
func (*Tester) HasCookie ¶
HasCookie checks if the response contains cookie with provided key and value.
func (*Tester) HasHeader ¶
HasHeader checks if the response contains header on provided key with provided value.
func (*Tester) HasHeaders ¶
HasHeaders checks if the response contains a provided headers map
func (*Tester) HasJson ¶
HasJson checks if the response body contains json with provided value. (deprecated)
func (*Tester) HasString ¶
HasString converts the response to a string type and then compares it with the given string.
func (*Tester) NotContainsBody ¶
NotContainsBody checks if the body does not contain provided [] byte data.
func (*Tester) NotContainsString ¶
NotContainsString converts the response to a string type and then checks if it does not contain the given string.
func (*Tester) WithBasicAuth ¶
WithBasicAuth is an alias to set basic auth in the request header.
func (*Tester) WithBearerAuth ¶ added in v1.5.0
WithBearerAuth is an alias to set bearer auth in the request header.
func (*Tester) WithCookie ¶
WithCookie puts cookie on the request.
func (*Tester) WithHeader ¶
WithHeader puts header on the request.
func (*Tester) WithHeaders ¶
WithHeaders puts a map of headers on the request.
func (*Tester) WithHostHeader ¶ added in v1.6.0
WithHostHeader puts "Host" header on the request.
func (*Tester) WithJson ¶
WithJson adds a json encoded struct to the body. (deprecated) nolint:golint
func (*Tester) WithString ¶
WithString adds the string to the body.