{"modulePath":"github.com/swithek/httpflow","version":"v0.0.0-20210302114855-3975a26f6022","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutil\n\nPackage testutil implements helper functions for more convenient testing and may be imported in '\\_test.go' files only. Usage of some of these functions would have to be replaced by the ones provided by the official testing toolkit packages, should they decide to include helper functions of similar logic and kind.\n\n## Functions\n\n```go\nfunc AssertEqualError(t *testing.T, exp, err error)\n```\nAssertEqualError uses testify's assert package to check if errors are equal or, if assert.AnError is expected, whether an error exists or not.\n\n```go\nfunc AssertFilterEqual(t *testing.T, v1, v2 interface{}, ignoreTypes []interface{})\n```\nAssertFilterEqual asserts that two objects are equal. All ignored types found on any of the provided objects will not be compared.\n\n```go\nfunc MockHTTP() (*http.Client, *httpmock.MockTransport)\n```\nMockHTTP returns mocked http environment.\n\n```go\nfunc QueryResponder(t *testing.T, resp httpmock.Responder, q url.Values) httpmock.Responder\n```\nQueryResponder asserts the required query values are present in the request.\n\n```go\nfunc RequireEqualError(t *testing.T, exp, err error)\n```\nRequireEqualError uses testify's require package to check if errors are equal or, if assert.AnError is expected, whether an error exists or not.\n\n```go\nfunc RequireFilterEqual(t *testing.T, v1, v2 interface{}, ignoreTypes []interface{})\n```\nRequireFilterEqual asserts that two objects are equal. All ignored types found on any of the provided objects will not be compared.\n\n## Types\n\n```go\ntype RoundTripperMock struct {\n\t// RoundTripFunc mocks the RoundTrip method.\n\tRoundTripFunc func(in1 *http.Request) (*http.Response, error)\n\t// contains filtered or unexported fields\n}\n```\nRoundTripperMock is a mock implementation of http.RoundTripper.\n\n\t    func TestSomethingThatUsesRoundTripper(t *testing.T) {\n\n\t        // make and configure a mocked http.RoundTripper\n\t        mockedRoundTripper := \u0026RoundTripperMock{\n\t            RoundTripFunc: func(in1 *http.Request) (*http.Response, error) {\n\t\t               panic(\"mock out the RoundTrip method\")\n\t            },\n\t        }\n\n\t        // use mockedRoundTripper in code that requires RoundTripper\n\t        // and then make assertions.\n\n\t    }\n\n```go\nfunc (mock *RoundTripperMock) RoundTrip(in1 *http.Request) (*http.Response, error)\n```\nRoundTrip calls RoundTripFunc.\n\n```go\nfunc (mock *RoundTripperMock) RoundTripCalls() []struct {\n\tIn1 *http.Request\n}\n```\nRoundTripCalls gets all the calls that were made to RoundTrip. Check the length with:\n\n\tlen(mockedRoundTripper.RoundTripCalls())\n\n","path":"github.com/swithek/httpflow/testutil","name":"testutil","synopsis":"Package testutil implements helper functions for more convenient testing and may be imported in '_test.go' files only.","isRedistributable":true}
