internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2018 License: Apache-2.0 Imports: 10 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 BeFileLike

func BeFileLike(t *testing.T, file string, mode os.FileMode, content string)

BeFileLike tests that a file exists, has a specific mode, and specific content.

func CaptureExitStatus

func CaptureExitStatus(t *testing.T) (*int, func())

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 DirectoryContents(root string) []string

func FileExists

func FileExists(file string) (bool, error)

func OsArgs

func OsArgs(index int) (string, error)

func ProtectEnv

func ProtectEnv(t *testing.T, keys ...string) func()

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

func ReplaceArgs(t *testing.T, args ...string) func()

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

func ReplaceEnv(t *testing.T, key string, value string) func()

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

func ReplaceWorkingDirectory(t *testing.T, dir string) func()

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

func ScratchDir(t *testing.T, prefix string) string

ScratchDir returns a safe scratch directory for tests to modify.

func ToTomlString

func ToTomlString(v interface{}) (string, error)

func WriteToFile

func WriteToFile(source io.Reader, destFile string, mode os.FileMode) error

Types

type Console

type Console struct {
	// contains filtered or unexported fields
}

Console represents the standard console objects, stdin, stdout, and stderr.

func ReplaceConsole

func ReplaceConsole(t *testing.T) (Console, func())

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()

func (Console) Err

func (c Console) Err(t *testing.T) string

Err returns a string representation of captured stderr.

func (Console) In

func (c Console) In(t *testing.T, string string)

In writes a string and closes the connection once complete.

func (Console) Out

func (c Console) Out(t *testing.T) string

Out returns a string representation of captured stdout.

Jump to

Keyboard shortcuts

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