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) []byte
- func BuildTestRequest(t *testing.T) *http.Request
- func CreateBodyFromStruct(t *testing.T, in interface{}) io.ReadCloser
- func CreateServiceUser(ctx context.Context, address, username string) (*types.User, error)
- func DetermineServiceURL() *url.URL
- func EnsureServerIsUp(ctx context.Context, address string)
- func GetLoginCookie(ctx context.Context, serviceURL string, u *types.User) (*http.Cookie, error)
- func IsUp(ctx context.Context, address string) bool
- func PreArchiveMessageMatcher(*types.PreArchiveMessage) bool
- func PreUpdateMessageMatcher(*types.PreUpdateMessage) bool
- func PreWriteMessageMatcher(*types.PreWriteMessage) bool
- type MockHTTPHandler
- type MockHTTPResponseWriter
- type MockReadCloser
Constants ¶
This section is empty.
Variables ¶
var ContextMatcher interface{} = mock.MatchedBy(func(context.Context) bool { return true })
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 HTTPRequestMatcher interface{} = mock.MatchedBy(func(*http.Request) bool { return true })
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 interface{} = 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.
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 CreateBodyFromStruct ¶
func CreateBodyFromStruct(t *testing.T, in interface{}) io.ReadCloser
CreateBodyFromStruct takes any value in and returns an io.ReadCloser for an http.Request's body.
func CreateServiceUser ¶
CreateServiceUser creates a user.
func DetermineServiceURL ¶
DetermineServiceURL returns the url, if properly configured.
func EnsureServerIsUp ¶
EnsureServerIsUp checks that a server is up and doesn't return until it's certain one way or the other.
func GetLoginCookie ¶
GetLoginCookie fetches a login cookie for a given user.
func PreArchiveMessageMatcher ¶
func PreArchiveMessageMatcher(*types.PreArchiveMessage) bool
PreArchiveMessageMatcher matches the types.PreArchiveMessage type.
func PreUpdateMessageMatcher ¶
func PreUpdateMessageMatcher(*types.PreUpdateMessage) bool
PreUpdateMessageMatcher matches the types.PreUpdateMessage type.
func PreWriteMessageMatcher ¶
func PreWriteMessageMatcher(*types.PreWriteMessage) bool
PreWriteMessageMatcher matches the types.PreWriteMessage type.
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.