Documentation
¶
Overview ¶
Package testutil contains helper functions for unit tests.
Index ¶
- func AssertProtoEqual(t *testing.T, expected, actual any, msgAndArgs ...any) bool
- func AssertProtoJSONEqual(t *testing.T, expected string, protoMsg any, msgAndArgs ...any) bool
- func AssertProtoJSONFileEqual(t *testing.T, file string, protoMsg any, msgAndArgs ...any) bool
- func CaptureLogs(t *testing.T, f func()) string
- func ModRoot() string
- func WithTestGCS(t *testing.T, bucket string, handler func() error) error
- func WithTestMinIO(t *testing.T, bucket string, handler func(endpoint string) error) error
- func WithTestPostgres(handler func(dsn string) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertProtoEqual ¶ added in v0.17.0
AssertProtoEqual asserts that two protobuf messages equal. Slices of messages are also supported.
func AssertProtoJSONEqual ¶ added in v0.9.0
AssertProtoJSONEqual asserts that a protobuf message matches the given JSON. The protoMsg can also be a slice of protobuf messages.
func AssertProtoJSONFileEqual ¶ added in v0.26.0
AssertProtoJSONFileEqual asserts that a protobuf message (or slice of messages) matches the given reference JSON file.
To update a reference JSON file, pass the test argument '-update'. This will overwrite the reference output to match the current behavior.
func CaptureLogs ¶ added in v0.25.0
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
WithTestGCS starts a GCS storage emulator.
func WithTestMinIO ¶ added in v0.21.0
WithTestMinIO starts a test MinIO server
func WithTestPostgres ¶ added in v0.18.0
WithTestPostgres starts a test DB and runs the given handler with the connection to it.
Types ¶
This section is empty.