Documentation
¶
Index ¶
- func AssertError(t *testing.T, err error, expectedMsg string)
- func AssertNoError(t *testing.T, err error)
- func CaptureStdout(t *testing.T) (string, func())
- func ClearEnv(t interface{ ... }, keys []string) func()
- func GetEnvMapFromStrings(envStrings []string) map[string]string
- func GitChildEnv(extra ...string) []string
- func HermeticGit(t *testing.T)
- func SetEnv(t interface{ ... }, env map[string]string) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertError ¶
AssertError asserts that an error is not nil and contains the expected message.
func AssertNoError ¶
AssertNoError asserts that an error is nil.
func CaptureStdout ¶
CaptureStdout captures the output of stdout during a test. It returns the captured string and a function to restore stdout.
func ClearEnv ¶
ClearEnv clears a list of environment variables. It returns a cleanup function that restores the original environment variables.
func GetEnvMapFromStrings ¶
GetEnvMapFromStrings converts a slice of "KEY=VALUE" strings into a map.
func GitChildEnv ¶ added in v4.24.9
GitChildEnv returns an environment for a git child process with the repository overrides dropped and global and system config neutralised, followed by extra (for example GIT_AUTHOR_NAME=t).
func HermeticGit ¶ added in v4.24.9
HermeticGit makes the current test independent of the git environment it inherited: the repository overrides are removed from the process for the duration of the test (restored on cleanup) and global and system config are neutralised. Use it when the code under test shells out to git, or reads a repository with go-git, and so inherits the process environment. Tests that call it must not run in parallel.
Types ¶
This section is empty.