Documentation
¶
Index ¶
- func BeFileLike(t *testing.T, file string, mode os.FileMode, content string)
- func CaptureExitStatus(t *testing.T) (*int, func())
- func DirectoryContents(root string) []string
- func FileExists(file string) (bool, error)
- func OsArgs(index int) (string, error)
- func ProtectEnv(t *testing.T, keys ...string) func()
- func ReplaceArgs(t *testing.T, args ...string) func()
- func ReplaceEnv(t *testing.T, key string, value string) func()
- func ReplaceWorkingDirectory(t *testing.T, dir string) func()
- func ScratchDir(t *testing.T, prefix string) string
- func ToTomlString(v interface{}) (string, error)
- func WriteToFile(source io.Reader, destFile string, mode os.FileMode) error
- type Console
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeFileLike ¶
BeFileLike tests that a file exists, has a specific mode, and specific content.
func CaptureExitStatus ¶
CaptureExitStatus returns a pointer to the exit status code when os.Exit() is called. Returns a function for use with defer in order to clean up after capture.
c, d := CaptureExitStatus(t) defer d()
func DirectoryContents ¶
func FileExists ¶
func ProtectEnv ¶
ProtectEnv protects a collection of environment variables. Returns a function for use with defer in order to reset the previous values.
defer ProtectEnv(t, "alpha")()
func ReplaceArgs ¶
ReplaceArgs replaces the current command line arguments (os.Args) with a new collection of values. Returns a function suitable for use with defer in order to reset the previous values
defer ReplaceArgs(t, "alpha")()
func ReplaceEnv ¶
ReplaceEnv replaces an environment variable. Returns a function for use with defer in order to reset the previous value.
defer ReplaceEnv(t, "alpha", "bravo")()
func ReplaceWorkingDirectory ¶
ReplaceWorkingDirectory replaces the current working directory (os.Getwd()) with a new value. Returns a function for use with defer in order to reset the previous value
defer ReplaceWorkingDirectory(t, "alpha")()
func ScratchDir ¶
ScratchDir returns a safe scratch directory for tests to modify.
func ToTomlString ¶
Types ¶
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console represents the standard console objects, stdin, stdout, and stderr.
func ReplaceConsole ¶
ReplaceConsole replaces the console files (os.Stderr, os.Stdin, os.Stdout). Returns a function for use with defer in order to reset the previous values
c, d := ReplaceConsole(t) defer d()