dep: Index | Files | Directories

package test

import ""


Package Files

test.go writer.go


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

func NeedsExternalNetwork Uses

func NeedsExternalNetwork(t *testing.T)

NeedsExternalNetwork makes sure the tests needing external network will not be run when executing tests in short mode.

func NeedsGit Uses

func NeedsGit(t *testing.T)

NeedsGit will make sure the tests that require git will be skipped if the git binary is not available.

type Helper Uses

type Helper struct {
    // contains filtered or unexported fields

Helper with utilities for testing.

func NewHelper Uses

func NewHelper(t *testing.T) *Helper

NewHelper initializes a new helper for testing.

func (*Helper) Cd Uses

func (h *Helper) Cd(dir string)

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) Cleanup Uses

func (h *Helper) Cleanup()

Cleanup cleans up a test that runs testgo.

func (*Helper) DoRun Uses

func (h *Helper) DoRun(args []string) error

DoRun runs the test go command, recording stdout and stderr and returning exit status.

func (*Helper) Exist Uses

func (h *Helper) Exist(path string) bool

Exist returns whether or not a path exists

func (*Helper) GetCommit Uses

func (h *Helper) GetCommit(repo string) string

GetCommit treats repo as a path to a git repository and returns the current revision.

func (*Helper) GetFile Uses

func (h *Helper) GetFile(path string) io.ReadCloser

GetFile reads a file into memory

func (*Helper) GetTestFile Uses

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 Uses

func (h *Helper) GetTestFileString(src string) string

GetTestFileString reads a file from the testdata directory into memory. src is relative to ./testdata.

func (*Helper) Must Uses

func (h *Helper) Must(err error)

Must gives a fatal error if err is not nil.

func (*Helper) MustExist Uses

func (h *Helper) MustExist(path string)

MustExist fails if path does not exist.

func (*Helper) MustNotExist Uses

func (h *Helper) MustNotExist(path string)

MustNotExist fails if path exists.

func (*Helper) Parallel Uses

func (h *Helper) Parallel()

Parallel runs the test in parallel by calling t.Parallel.

func (*Helper) Path Uses

func (h *Helper) Path(name string) string

Path returns the absolute pathname to file with the temporary directory.

func (*Helper) ReadLock Uses

func (h *Helper) ReadLock() string

ReadLock returns the lock in the current directory.

func (*Helper) ReadManifest Uses

func (h *Helper) ReadManifest() string

ReadManifest returns the manifest in the current directory.

func (*Helper) Run Uses

func (h *Helper) Run(args ...string)

Run runs the test go command, and expects it to succeed.

func (*Helper) RunGit Uses

func (h *Helper) RunGit(dir string, args ...string)

RunGit runs a git command, and expects it to succeed.

func (*Helper) RunGo Uses

func (h *Helper) RunGo(args ...string)

RunGo runs a go command, and expects it to succeed.

func (*Helper) Setenv Uses

func (h *Helper) Setenv(name, val string)

Setenv sets an environment variable to use when running the test go command.

func (*Helper) ShouldExist Uses

func (h *Helper) ShouldExist(path string) error

ShouldExist returns an error if path does not exist.

func (*Helper) ShouldNotExist Uses

func (h *Helper) ShouldNotExist(path string) error

ShouldNotExist returns an error if path exists.

func (*Helper) TempCopy Uses

func (h *Helper) TempCopy(dest, src string)

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 Uses

func (h *Helper) TempDir(path string)

TempDir adds a temporary directory for a run of testgo.

func (*Helper) TempFile Uses

func (h *Helper) TempFile(path, contents string)

TempFile adds a temporary file for a run of testgo.

func (*Helper) WriteTestFile Uses

func (h *Helper) WriteTestFile(src string, content string) error

WriteTestFile writes a file to the testdata directory from memory. src is relative to ./testdata.

type Writer Uses

type Writer struct {

Writer adapts a testing.TB to the io.Writer interface

func (Writer) Write Uses

func (t Writer) Write(b []byte) (n int, err error)



Package test imports 16 packages (graph) and is imported by 19 packages. Updated 2019-06-23. Refresh now. Tools for package owners.