Documentation ¶
Index ¶
- Variables
- func NeedsExternalNetwork(t *testing.T)
- func NeedsGit(t *testing.T)
- type Helper
- func (h *Helper) Cd(dir string)
- func (h *Helper) Cleanup()
- func (h *Helper) DoRun(args []string) error
- func (h *Helper) Exist(path string) bool
- func (h *Helper) GetCommit(repo string) string
- func (h *Helper) GetFile(path string) io.ReadCloser
- func (h *Helper) GetTestFile(src string) io.ReadCloser
- func (h *Helper) GetTestFileString(src string) string
- func (h *Helper) Must(err error)
- func (h *Helper) MustExist(path string)
- func (h *Helper) MustNotExist(path string)
- func (h *Helper) Parallel()
- func (h *Helper) Path(name string) string
- func (h *Helper) ReadLock() string
- func (h *Helper) ReadManifest() string
- func (h *Helper) Run(args ...string)
- func (h *Helper) RunGit(dir string, args ...string)
- func (h *Helper) RunGo(args ...string)
- func (h *Helper) Setenv(name, val string)
- func (h *Helper) ShouldExist(path string) error
- func (h *Helper) ShouldNotExist(path string) error
- func (h *Helper) TempCopy(dest, src string)
- func (h *Helper) TempDir(path string)
- func (h *Helper) TempFile(path, contents string)
- func (h *Helper) WriteTestFile(src string, content string) error
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( // ExeSuffix is the suffix of executable files; ".exe" on Windows. ExeSuffix string // PrintLogs controls logging of test commands. PrintLogs = flag.Bool("logs", false, "log stdin/stdout of test commands") // UpdateGolden controls updating test fixtures. UpdateGolden = flag.Bool("update", false, "update golden files") )
Functions ¶
func NeedsExternalNetwork ¶
NeedsExternalNetwork makes sure the tests needing external network will not be run when executing tests in short mode.
Types ¶
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper with utilities for testing.
func NewHelper ¶
NewHelper initializes a new helper for testing.
func (*Helper) Cd ¶
Cd changes the current directory to the named directory. Note that using this means that the test must not be run in parallel with any other tests.
func (*Helper) DoRun ¶
DoRun runs the test go command, recording stdout and stderr and returning exit status.
func (*Helper) Exist ¶
Exist returns whether or not a path exists
func (*Helper) GetCommit ¶
GetCommit treats repo as a path to a git repository and returns the current revision.
func (*Helper) GetFile ¶
func (h *Helper) GetFile(path string) io.ReadCloser
GetFile reads a file into memory
func (*Helper) GetTestFile ¶
func (h *Helper) GetTestFile(src string) io.ReadCloser
GetTestFile reads a file from the testdata directory into memory. src is relative to ./testdata.
func (*Helper) GetTestFileString ¶
GetTestFileString reads a file from the testdata directory into memory. src is relative to ./testdata.
func (*Helper) MustExist ¶
MustExist fails if path does not exist.
func (*Helper) MustNotExist ¶
MustNotExist fails if path exists.
func (*Helper) Parallel ¶
func (h *Helper) Parallel()
Parallel runs the test in parallel by calling t.Parallel.
func (*Helper) Path ¶
Path returns the absolute pathname to file with the temporary directory.
func (*Helper) ReadLock ¶
ReadLock returns the lock in the current directory.
func (*Helper) ReadManifest ¶
ReadManifest returns the manifest in the current directory.
func (*Helper) Run ¶
Run runs the test go command, and expects it to succeed.
func (*Helper) RunGit ¶
RunGit runs a git command, and expects it to succeed.
func (*Helper) RunGo ¶
RunGo runs a go command, and expects it to succeed.
func (*Helper) Setenv ¶
Setenv sets an environment variable to use when running the test go command.
func (*Helper) ShouldExist ¶
ShouldExist returns an error if path does not exist.
func (*Helper) ShouldNotExist ¶
ShouldNotExist returns an error if path exists.
func (*Helper) TempCopy ¶
TempCopy copies a temporary file from testdata into the temporary directory. dest is relative to the temp directory location, and src is relative to ./testdata.
func (*Helper) TempDir ¶
TempDir adds a temporary directory for a run of testgo.
func (*Helper) TempFile ¶
TempFile adds a temporary file for a run of testgo.