Documentation
¶
Index ¶
- func CaptureStderr(fnToExec func()) (string, error)
- func CaptureStdout(fnToExec func()) (string, error)
- func CopyTestFileToConfigDir(configPath, testFileName, targetFileName string, targetFileMode os.FileMode) error
- func CreateConfigFile(configPath string, fileName string, fileMode os.FileMode) (*os.File, error)
- func GetTestDataDir() string
- func GetTestFile(fileName ...string) string
- func PrepareDir(path string) string
- func ReadConfigFile(configPath, fileName string) (string, error)
- func ReadTestFile(fileName string) (string, error)
- func RemoveConfigFile(configPath, fileName string) error
- func StatConfigFile(configPath, fileName string) (os.FileInfo, error)
- func WrapStdin(fnToExec func(), inputLines ...interface{})
- func WrapStdinWithDelay(delay time.Duration, fnToExec func(), inputLines ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureStderr ¶
CaptureStderr will execute a provided function and capture anything written to stderr. It will then return that output as a string along with any errors captured in the process.
func CaptureStdout ¶
CaptureStdout will execute a provided function and capture anything written to stdout. It will then return that output as a string along with any errors captured in the process.
func CopyTestFileToConfigDir ¶
func CopyTestFileToConfigDir(configPath, testFileName, targetFileName string, targetFileMode os.FileMode) error
CopyTestFileToConfigDir copies a file in a relatve `testdata` dir to the caller of this function to the config dir as some target filename with some target FileMode.
func CreateConfigFile ¶
CreateConfigFile will create a file in the config dir with the given file name.
func GetTestDataDir ¶
func GetTestDataDir() string
GetTestDataDir returns the path to the caller's `testdata` directory.
func GetTestFile ¶
GetTestFile returns the path to the given fileName in the calling function's `testdata` directory.
func PrepareDir ¶
PrepareDir prepares a path for use in tests (ensures it exists and ensures the path is concistent)
func ReadConfigFile ¶
ReadConfigFile will read the contents of a file in the config dir.
func ReadTestFile ¶
ReadTestFile will read the contents of a file from the `testdata` directory relative to the path of the calling function file. This function assumes it is called directly from a function in a file in the directory the `testdata` exists in.
func RemoveConfigFile ¶
RemoveConfigFile will remove a file from the config dir with the given file name.
func StatConfigFile ¶
StatConfigFile returns the os.FileInfo for a file in the config dir.
func WrapStdin ¶
func WrapStdin(fnToExec func(), inputLines ...interface{})
WrapStdin will fill stdin with the lines provided as a variadic list of strings before executing the provided function. Each line will be appended with a newline (\n) only.
func WrapStdinWithDelay ¶
WrapStdinWithDelay will fill stdin with the lines provided, but with a given delay before each write. This is useful if there is a reader that reads all of stdin between prompts, for instance.
Types ¶
This section is empty.