Documentation
¶
Index ¶
- func Abs(t *testing.T, path string) string
- func CheckContains(t *testing.T, expected, actual string)
- func CheckDeepEqual(t *testing.T, expected, actual interface{}, opts ...cmp.Option)
- func CheckElementsMatch(t *testing.T, expected, actual interface{})
- func CheckError(t *testing.T, shouldErr bool, err error)
- func CheckErrorAndDeepEqual(t *testing.T, shouldErr bool, err error, expected, actual interface{}, ...)
- func CheckErrorAndExitCode(t *testing.T, expectedCode int, err error)
- func CheckErrorAndFailNow(t *testing.T, shouldErr bool, err error)
- func CheckFileExistAndContent(t *testing.T, path string, expectedContent []byte)
- func CheckMapsMatch(t *testing.T, expected, actual interface{})
- func CheckNotContains(t *testing.T, excluded, actual string)
- func CheckRegex(t *testing.T, pattern, actual string)
- func EnsureTestPanicked(t *testing.T)
- func Run(t *testing.T, name string, f func(t *T))
- func ServeFile(t *testing.T, content []byte) string
- func TempFile(t *testing.T, prefix string, content []byte) string
- type FakeCmd
- func CmdRun(command string) *FakeCmd
- func CmdRunDirOut(command string, dir string, output string) *FakeCmd
- func CmdRunEnv(command string, env []string) *FakeCmd
- func CmdRunErr(command string, err error) *FakeCmd
- func CmdRunInputOut(command string, input string, output string) *FakeCmd
- func CmdRunOut(command string, output string) *FakeCmd
- func CmdRunOutErr(command string, output string, err error) *FakeCmd
- func CmdRunWithOutput(command, output string) *FakeCmd
- func (c *FakeCmd) AndRun(command string) *FakeCmd
- func (c *FakeCmd) AndRunDirOut(command string, dir string, output string) *FakeCmd
- func (c *FakeCmd) AndRunEnv(command string, env []string) *FakeCmd
- func (c *FakeCmd) AndRunErr(command string, err error) *FakeCmd
- func (c *FakeCmd) AndRunInput(command, input string) *FakeCmd
- func (c *FakeCmd) AndRunInputOut(command string, input string, output string) *FakeCmd
- func (c *FakeCmd) AndRunOut(command string, output string) *FakeCmd
- func (c *FakeCmd) AndRunOutErr(command string, output string, err error) *FakeCmd
- func (c *FakeCmd) AndRunWithOutput(command, output string) *FakeCmd
- func (c *FakeCmd) ForTest(t *testing.T)
- func (c *FakeCmd) RunCmd(ctx context.Context, cmd *exec.Cmd) error
- func (c *FakeCmd) RunCmdOut(ctx context.Context, cmd *exec.Cmd) ([]byte, error)
- func (c *FakeCmd) TimesCalled() int
- type FakeFileSystem
- type ForTester
- type T
- func (t *T) Chdir(dir string)
- func (t *T) CheckContains(expected, actual string)
- func (t *T) CheckDeepEqual(expected, actual interface{}, opts ...cmp.Option)
- func (t *T) CheckElementsMatch(expected, actual interface{})
- func (t *T) CheckEmpty(actual interface{})
- func (t *T) CheckError(shouldErr bool, err error)
- func (t *T) CheckErrorAndDeepEqual(shouldErr bool, err error, expected, actual interface{}, opts ...cmp.Option)
- func (t *T) CheckErrorAndExitCode(expectedCode int, err error)
- func (t *T) CheckErrorAndFailNow(shouldErr bool, err error)
- func (t *T) CheckErrorContains(message string, err error)
- func (t *T) CheckFalse(actual bool)
- func (t *T) CheckFileExistAndContent(filePath string, expectedContent []byte)
- func (t *T) CheckMapsMatch(expected, actual interface{})
- func (t *T) CheckMatches(pattern, actual string)
- func (t *T) CheckNil(actual interface{})
- func (t *T) CheckNoError(err error)
- func (t *T) CheckNotNil(actual interface{})
- func (t *T) CheckTrue(actual bool)
- func (t *T) CheckTypeEquality(expected, actual interface{})
- func (t *T) NewTempDir() *TempDir
- func (t *T) Override(dest, tmp interface{})
- func (t *T) RequireNoError(err error)
- func (t *T) RequireNonNilResult(x interface{}, err error) interface{}
- func (t *T) SetArgs(args []string)
- func (t *T) SetEnvs(envs map[string]string)
- func (t *T) SetStdin(content []byte)
- func (t *T) TempFile(prefix string, content []byte) string
- type TempDir
- func (h *TempDir) Chdir() *TempDir
- func (h *TempDir) Chtimes(file string, t time.Time) *TempDir
- func (h *TempDir) List() ([]string, error)
- func (h *TempDir) Mkdir(dir string) *TempDir
- func (h *TempDir) Path(file string) string
- func (h *TempDir) Paths(files ...string) []string
- func (h *TempDir) Remove(file string) *TempDir
- func (h *TempDir) Rename(oldName, newName string) *TempDir
- func (h *TempDir) Root() string
- func (h *TempDir) Symlink(dst, src string) *TempDir
- func (h *TempDir) Touch(files ...string) *TempDir
- func (h *TempDir) Write(file, content string) *TempDir
- func (h *TempDir) WriteFiles(files map[string]string) *TempDir
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckContains ¶
func CheckDeepEqual ¶
func CheckElementsMatch ¶
CheckElementsMatch validates that two given slices contain the same elements while disregarding their order. Elements of both slices have to be comparable by '=='
func CheckErrorAndDeepEqual ¶
func CheckMapsMatch ¶
CheckMapsMatch validates that two given maps contain the same key-value pairs
func CheckNotContains ¶
func CheckRegex ¶
func EnsureTestPanicked ¶
Types ¶
type FakeCmd ¶
type FakeCmd struct {
// contains filtered or unexported fields
}
func CmdRunWithOutput ¶
CmdRunWithOutput programs the fake runner with a command and expected output
func (*FakeCmd) AndRunDirOut ¶
func (*FakeCmd) AndRunInput ¶
func (*FakeCmd) AndRunInputOut ¶
func (*FakeCmd) AndRunOutErr ¶
func (*FakeCmd) AndRunWithOutput ¶
AndRunWithOutput takes a command and an expected output. It expected to match up with a call to RunCmd, and pipes the provided output to RunCmd's exec.Cmd's stdout.
func (*FakeCmd) TimesCalled ¶
type FakeFileSystem ¶
type T ¶
func (*T) CheckContains ¶
func (*T) CheckDeepEqual ¶
func (*T) CheckElementsMatch ¶
func (t *T) CheckElementsMatch(expected, actual interface{})
CheckElementsMatch validates that two given slices contain the same elements while disregarding their order. Elements of both slices have to be comparable by '=='
func (*T) CheckEmpty ¶
func (t *T) CheckEmpty(actual interface{})
func (*T) CheckError ¶
func (*T) CheckErrorAndDeepEqual ¶
func (*T) CheckErrorAndExitCode ¶
func (*T) CheckErrorAndFailNow ¶
CheckErrorAndFailNow checks that the provided error complies with whether or not we expect an error and fails the test execution immediately if it does not. Useful for testing functions which return (obj interface{}, e error) and subsequent checks operate on `obj` assuming that it is not nil.
func (*T) CheckErrorContains ¶
CheckErrorContains checks that an error is not nil and contains a given message.
func (*T) CheckFalse ¶
func (*T) CheckFileExistAndContent ¶
CheckFileExistAndContent checks if the given file path exists and the content is expected.
func (*T) CheckMapsMatch ¶
func (t *T) CheckMapsMatch(expected, actual interface{})
CheckMapsMatch validates that two given maps contain the same key value pairs.
func (*T) CheckMatches ¶
func (*T) CheckNoError ¶
func (*T) CheckNotNil ¶
func (t *T) CheckNotNil(actual interface{})
func (*T) CheckTypeEquality ¶
func (t *T) CheckTypeEquality(expected, actual interface{})
func (*T) NewTempDir ¶
func (*T) RequireNoError ¶
func (*T) RequireNonNilResult ¶
func (*T) SetEnvs ¶
SetEnvs takes a map of key values to set using t.Setenv and restore the environment variable to its original value after the test.
type TempDir ¶
type TempDir struct {
// contains filtered or unexported fields
}
TempDir offers actions on a temp directory.
func NewTempDir ¶
NewTempDir creates a temporary directory and a teardown function that should be called to properly delete the directory content.