testutil

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package testutil contains helper functions for unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertProtoEqual added in v0.17.0

func AssertProtoEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) bool

AssertProtoEqual asserts that two protobuf messages equal. Slices of messages are also supported.

func AssertProtoJSONEqual added in v0.9.0

func AssertProtoJSONEqual(t *testing.T, expected string, protoMsg interface{}, msgAndArgs ...interface{}) bool

AssertProtoJSONEqual asserts that a protobuf message matches the given JSON. The protoMsg can also be a slice of protobuf messages.

func CaptureLogs added in v0.25.0

func CaptureLogs(t *testing.T, f func()) string

CaptureLogs captures any logs made during the test. Time will be stripped. Any tests that use it should not be run in parallel.

func ModRoot added in v0.14.0

func ModRoot() string

ModRoot returns the directory containing the go.mod file.

func WithTestGCS added in v0.21.0

func WithTestGCS(t *testing.T, bucket string, handler func() error) error

WithTestGCS starts a GCS storage emulator.

func WithTestMinIO added in v0.21.0

func WithTestMinIO(t *testing.T, bucket string, handler func(endpoint string) error) error

WithTestMinIO starts a test MinIO server

func WithTestPostgres added in v0.18.0

func WithTestPostgres(handler func(dsn string) error) error

WithTestPostgres starts a test DB and runs the given handler with the connection to it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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