testutils

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNoError added in v0.0.3

func CheckNoError(t *testing.T, err error)

func CheckNoServerError added in v0.0.9

func CheckNoServerError(t *testing.T, err error)

func CopyHeaders added in v0.2.0

func CopyHeaders(from http.Header, to http.Header)

func CreateServerCert added in v0.6.1

func CreateServerCert(t *testing.T, caCert *x509.Certificate, caKey *rsa.PrivateKey, host string) tls.Certificate

func CurrentDir added in v0.3.0

func CurrentDir(t *testing.T) string

func FsFromMap added in v0.0.8

func FsFromMap(t *testing.T, files map[string]string) afero.Fs

FsFromMap creates afero.Fs in memory from map. Where key is a filename and value is file context.

func GetFreePort added in v0.6.1

func GetFreePort(t *testing.T) int

func GetFreePorts added in v0.6.1

func GetFreePorts(t *testing.T, count int) []int

func IsPortFree added in v0.6.1

func IsPortFree(port int) bool

func JoinPath added in v0.6.1

func JoinPath(base string, elem ...string) string

func LogTest added in v0.0.7

func LogTest(action func(t *testing.T, output *bytes.Buffer)) func(t *testing.T)

func MatchSnapshot added in v0.6.0

func MatchSnapshot(t *testing.T, values ...any)

MatchSnapshot matches the given value against a snapshot.

func NewTestClient

func NewTestClient(responseCreator RoundTripFunc) *http.Client

func ReadBody added in v0.0.6

func ReadBody(t *testing.T, recorder *httptest.ResponseRecorder) string

func ReadHeader added in v0.0.7

func ReadHeader(t *testing.T, recorder *httptest.ResponseRecorder) http.Header

func SetMuxVars added in v0.6.0

func SetMuxVars(req *http.Request, vars map[string]string) *http.Request

SetMuxVars sets gorilla/mux route variables for testing.

func SetupHTTPSTest added in v0.6.0

func SetupHTTPSTest(t *testing.T, fs afero.Fs) *http.Client

SetupHTTPSTest sets up CA for HTTPS tests and returns HTTP client with proper TLS config.

func Times added in v0.2.0

func Times(n int, function func(n int))

func UniqOutput added in v0.3.0

func UniqOutput(output *bytes.Buffer, action func(t *testing.T, output *bytes.Buffer)) func(t *testing.T)

func WithTrueColor added in v0.3.0

func WithTrueColor(action func(t *testing.T)) func(t *testing.T)

Types

type CountableHandler added in v0.2.0

type CountableHandler struct {
	// contains filtered or unexported fields
}

func NewCounter added in v0.2.0

func NewCounter(handler handlerFunc) *CountableHandler

func (*CountableHandler) Count added in v0.2.0

func (t *CountableHandler) Count() int

func (*CountableHandler) Reset added in v0.2.0

func (t *CountableHandler) Reset()

func (*CountableHandler) ServeHTTP added in v0.2.0

func (t *CountableHandler) ServeHTTP(writer contracts.ResponseWriter, request *contracts.Request)

type QueueEvents added in v0.6.1

type QueueEvents struct {
	// contains filtered or unexported fields
}

func (*QueueEvents) List added in v0.6.1

func (q *QueueEvents) List() []string

func (*QueueEvents) Track added in v0.6.1

func (q *QueueEvents) Track(event string)

type RoundTripFunc

type RoundTripFunc func(req *http.Request) *http.Response

func (RoundTripFunc) RoundTrip

func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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