Documentation ¶
Overview ¶
Package testutils contains common functions for integration/load tests
Index ¶
- Variables
- func BrokenSessionContextDataFetcher(*http.Request) (*types.SessionContextData, error)
- func BuildArbitraryImage(widthAndHeight int) image.Image
- func BuildArbitraryImagePNGBytes(widthAndHeight int) (img image.Image, imgBytes []byte)
- func BuildTestRequest(t *testing.T) *http.Request
- func CreateServiceUser(ctx context.Context, address string, in *types.UserRegistrationInput) (*types.User, error)
- func GetLoginCookie(ctx context.Context, serviceURL string, u *types.User) (*http.Cookie, error)
- type MockHTTPHandler
- type MockHTTPResponseWriter
- type MockReadCloser
Constants ¶
This section is empty.
Variables ¶
ContextMatcher is a matcher for use with testify/mock's MatchBy function. It provides some level of type safety reassurance over mock.Anything, in that the resulting function will panic if anything other than a context.Context.
var DataChangeMessageMatcher any = mock.MatchedBy(func(*types.DataChangeMessage) bool { return true })
DataChangeMessageMatcher is a matcher for the types.DataChangeMessage interface. It provides some level of type safety reassurance over mock.Anything, in that the resulting function will panic if anything other than a http.ResponseWriter.
HTTPRequestMatcher is a matcher for use with testify/mock's MatchBy function. It provides some level of type safety reassurance over mock.Anything, in that the resulting function will panic if anything other than a *http.Request.
var HTTPResponseWriterMatcher any = mock.MatchedBy(func(http.ResponseWriter) bool { return true })
HTTPResponseWriterMatcher is a matcher for the http.ResponseWriter interface. It provides some level of type safety reassurance over mock.Anything, in that the resulting function will panic if anything other than a http.ResponseWriter.
var QueryFilterMatcher any = mock.MatchedBy(func(*types.QueryFilter) bool { return true })
QueryFilterMatcher is a matcher for use with testify/mock's MatchBy function. It provides some level of type safety reassurance over mock.Anything, in that the resulting function will panic if anything other than a context.Context.
Functions ¶
func BrokenSessionContextDataFetcher ¶
func BrokenSessionContextDataFetcher(*http.Request) (*types.SessionContextData, error)
BrokenSessionContextDataFetcher is a deliberately broken sessionContextDataFetcher.
func BuildArbitraryImage ¶
BuildArbitraryImage builds an image with a bunch of colors in it.
func BuildArbitraryImagePNGBytes ¶
BuildArbitraryImagePNGBytes builds an image with a bunch of colors in it.
func BuildTestRequest ¶
BuildTestRequest builds an arbitrary *http.Request.
func CreateServiceUser ¶
func CreateServiceUser(ctx context.Context, address string, in *types.UserRegistrationInput) (*types.User, error)
CreateServiceUser creates a user.
Types ¶
type MockHTTPHandler ¶
MockHTTPHandler is a mocked http.Handler.
func (*MockHTTPHandler) ServeHTTP ¶
func (m *MockHTTPHandler) ServeHTTP(res http.ResponseWriter, req *http.Request)
ServeHTTP satisfies our interface requirements.
type MockHTTPResponseWriter ¶
MockHTTPResponseWriter is a mock http.ResponseWriter.
func (*MockHTTPResponseWriter) Header ¶
func (m *MockHTTPResponseWriter) Header() http.Header
Header satisfies our interface requirements.
func (*MockHTTPResponseWriter) Write ¶
func (m *MockHTTPResponseWriter) Write(in []byte) (int, error)
Write satisfies our interface requirements.
func (*MockHTTPResponseWriter) WriteHeader ¶
func (m *MockHTTPResponseWriter) WriteHeader(statusCode int)
WriteHeader satisfies our interface requirements.
type MockReadCloser ¶
MockReadCloser mocks a io.ReadCloser.
func (*MockReadCloser) Close ¶
func (m *MockReadCloser) Close() (err error)
Close implements the io.ReadCloser interface.