Documentation ¶
Index ¶
- func EquateApproxTime(margin time.Duration) cmp.Option
- func IgnoreField(name string) cmp.Option
- func IgnoreUnexported(types ...interface{}) cmp.Option
- func NotEmpty(name string) cmp.Option
- func ParseHTML(t *testing.T, body string) *goquery.Document
- func ParseURL(t *testing.T, href string) *url.URL
- func SortSlices(lessFunc interface{}) cmp.Option
- type HTTP
- type TestOption
- func ExpectHeader(name, value string) TestOption
- func ExpectJSONResponse(output interface{}, compareOpt ...cmp.Option) TestOption
- func ExpectRawResponse(body []byte) TestOption
- func ExpectStatusCode(code int) TestOption
- func FatalFailure(parentContext *testing.T) TestOption
- func GrabJSONResponse(out interface{}) TestOption
- func WithCookieJar(jar *cookiejar.Jar) TestOption
- func WithFormInput(values url.Values) TestOption
- func WithHeader(name, value string) TestOption
- func WithInput(r io.Reader) TestOption
- func WithJSONInput(input interface{}) TestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IgnoreField ¶
IgnoreField is a comparison option that ignores the given field, like "Foo" or "Foo.Bar".
func IgnoreUnexported ¶
func NotEmpty ¶
NotEmpty is a comparison option that requires both things to not be empty. That is, different from their zero values.
func SortSlices ¶
Types ¶
type TestOption ¶
type TestOption func(*testCase)
func ExpectHeader ¶
func ExpectHeader(name, value string) TestOption
ExpectStatusCode specifies an expected HTTP header of the response.
func ExpectJSONResponse ¶
func ExpectJSONResponse(output interface{}, compareOpt ...cmp.Option) TestOption
ExpectJSONResponse specifies a JSON object that should match the response. The response will be decoded into the same type as the specified output and compared. Comparison options can be specified.
func ExpectRawResponse ¶
func ExpectRawResponse(body []byte) TestOption
ExpectRawResponse specifies the exact body expected of the response.
func ExpectStatusCode ¶
func ExpectStatusCode(code int) TestOption
ExpectStatusCode specifies the expected HTTP status code of the response.
func FatalFailure ¶
func FatalFailure(parentContext *testing.T) TestOption
FatalFailure will make this fatally fail in the given test context.
func GrabJSONResponse ¶
func GrabJSONResponse(out interface{}) TestOption
GrabJSONResponse takes a pointer to an object and unmarshals the response into it. Use this for examining data outside of the test.
func WithCookieJar ¶ added in v0.2.0
func WithCookieJar(jar *cookiejar.Jar) TestOption
func WithFormInput ¶
func WithFormInput(values url.Values) TestOption
WithInput specifies the form request body data for this test and expects application/x-www-form-urlencoded Content-Type. The header expectation can be overriden with WithHeader.
func WithHeader ¶
func WithHeader(name, value string) TestOption
WithHeader specifies a header to be added to the request for this test.
func WithInput ¶
func WithInput(r io.Reader) TestOption
WithInput specifies the request body data for this test.
func WithJSONInput ¶
func WithJSONInput(input interface{}) TestOption
WithInput specifies the JSON request body data for this test and expects application/json Content-Type. The header expectation can be overriden with WithHeader.