testutils

package
v3.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutils contains common functions for integration/load tests

Index

Constants

View Source
const (
	Example32ByteKey = "HEREISA32CHARSECRETWHICHISMADEUP"
	Example64ByteKey = "HEREISA64CHARSECRETWHICHISMADEUPHEREISA64CHARSECRETWHICHISMADEUP"
)

Variables

View Source
var (
	ContextMatcher            = MatchType[context.Context]()
	QueryFilterMatcher        = MatchType[*filtering.QueryFilter]()
	HTTPRequestMatcher        = MatchType[*http.Request]()
	HTTPResponseWriterMatcher = MatchType[http.ResponseWriter]()
)

Functions

func BuildArbitraryImage

func BuildArbitraryImage(widthAndHeight int) image.Image

BuildArbitraryImage builds an image with a bunch of colors in it.

func BuildArbitraryImagePNGBytes

func BuildArbitraryImagePNGBytes(widthAndHeight int) (img image.Image, imgBytes []byte)

BuildArbitraryImagePNGBytes builds an image with a bunch of colors in it.

func BuildTestRequest

func BuildTestRequest(t *testing.T) *http.Request

BuildTestRequest builds an arbitrary *http.Request.

func MatchType

func MatchType[T any]() any

MatchType is a matcher for use with testify/mock.

Types

type MockHTTPHandler

type MockHTTPHandler struct {
	mock.Mock
}

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

type MockHTTPResponseWriter struct {
	mock.Mock
}

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

type MockReadCloser struct {
	mock.Mock
}

MockReadCloser mocks a io.ReadCloser.

func (*MockReadCloser) Close

func (m *MockReadCloser) Close() error

Close implements the io.ReadCloser interface.

func (*MockReadCloser) Read

func (m *MockReadCloser) Read(p []byte) (int, error)

Read implements the io.ReadCloser interface.

type MockWriter

type MockWriter struct {
	mock.Mock
}

MockWriter mocks a io.Writer.

func (*MockWriter) Write

func (m *MockWriter) Write(p []byte) (int, error)

Write implements the io.Writer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL