testutils

package
v4.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertError

func AssertError(t *testing.T, err error, expectedMsg string)

AssertError asserts that an error is not nil and contains the expected message.

func AssertNoError

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

AssertNoError asserts that an error is nil.

func CaptureStdout

func CaptureStdout(t *testing.T) (string, func())

CaptureStdout captures the output of stdout during a test. It returns the captured string and a function to restore stdout.

func ClearEnv

func ClearEnv(t interface {
	Helper()
	Setenv(key, value string)
}, keys []string) func()

ClearEnv clears a list of environment variables. It returns a cleanup function that restores the original environment variables.

func GetEnvMapFromStrings

func GetEnvMapFromStrings(envStrings []string) map[string]string

GetEnvMapFromStrings converts a slice of "KEY=VALUE" strings into a map.

func SetEnv

func SetEnv(t interface {
	Helper()
	Setenv(key, value string)
}, env map[string]string) func()

SetEnv temporarily sets environment variables for the duration of a test. It returns a cleanup function that restores the original environment variables.

Types

This section is empty.

Jump to

Keyboard shortcuts

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