Documentation
¶
Index ¶
- func Argument(index int) (string, error)
- func DirectoryContents(root string) ([]string, error)
- func FileExists(file string) (bool, error)
- func HaveContent(expected string) types.GomegaMatcher
- 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 TouchTestFile(t *testing.T, elem ...string)
- func WriteFile(filename string, perm os.FileMode, format string, args ...interface{}) error
- func WriteTestFile(t *testing.T, filename string, format string, args ...interface{})
- func WriteTomlFile(filename string, perm os.FileMode, value interface{}) error
- type Console
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Argument ¶
Argument returns the specified argument from os.Args. It returns an error if there are not enough arguments to satisfy the request.
func DirectoryContents ¶
DirectoryContents walks the tree of files below a given root and returns their relative paths.
func FileExists ¶
FileExists returns whether a file exists taking into account various error cases.
func HaveContent ¶
func HaveContent(expected string) types.GomegaMatcher
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 TouchTestFile ¶
TouchTestFile writes a zero-length file during testing.
func WriteFile ¶
WriteFile writes a file with the given content. Before writing, it creates all required parent directories for the file.
func WriteTestFile ¶
WriteTestFile writes a file during testing.
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()