Documentation ¶
Index ¶
- func AssertErrorMatch(t *testing.T, err error, re *regexp.Regexp, msgAndArgs ...interface{}) bool
- func AssertFileDoesNotExist(t *testing.T, path string, msgAndArgs ...interface{}) bool
- func AssertFileExists(t *testing.T, path string, msgAndArgs ...interface{}) bool
- func AssertPanicsMatch(t *testing.T, fn func(), re *regexp.Regexp, msgAndArgs ...interface{}) bool
- func Measure(fn func()) time.Duration
- type Sandbox
- func (sb *Sandbox) Cleanup() error
- func (sb *Sandbox) ContainsPath(path string) bool
- func (sb *Sandbox) Mkdir(p string, mode os.FileMode) (string, error)
- func (sb *Sandbox) Normalize(path string) string
- func (sb *Sandbox) Symlink(oldname, newname string) (string, error)
- func (sb *Sandbox) TempFile(args ...string) string
- func (sb *Sandbox) Touch(file string) string
- func (sb *Sandbox) Track(p string)
- func (sb *Sandbox) Write(path string, data string) (string, error)
- func (sb *Sandbox) WriteFile(path string, data []byte, mode os.FileMode) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErrorMatch ¶
AssertErrorMatch fails the test t if err is nil or if its message does not match the provided regexp re
func AssertFileDoesNotExist ¶
AssertFileDoesNotExist failts the test t if path exists
func AssertFileExists ¶
AssertFileExists failts the test t if path does not exists
func AssertPanicsMatch ¶
AssertPanicsMatch fails the test t if fn does not panic or if the panic message does not match the provided regexp re
Types ¶
type Sandbox ¶
type Sandbox struct { sync.RWMutex // Root of the sandbox Root string // contains filtered or unexported fields }
Sandbox allows manipulating files and directories with paths sandboxed into the Root directory
func NewSandbox ¶
NewSandbox returns a new sandbox with the configured root or a random temporary one if none is provided
func (*Sandbox) ContainsPath ¶
ContainsPath returns true if path is contained inside the sandbox and false otherwise. This function does not check for the existence of the file, just checks if the path is contained in the sanbox root
func (*Sandbox) Normalize ¶
Normalize returns the fully normalized version of path, including the Root prefix
func (*Sandbox) TempFile ¶
TempFile returns a temporary non-existent file. An optional file tail can be provided