testcontext

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 3 * time.Minute

DefaultTimeout is the default timeout used by new context

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

Context is a context that has utility methods for testing and waiting for asynchronous errors.

func New

func New(test TB) *Context

New creates a new test context with default timeout

func NewWithTimeout

func NewWithTimeout(test TB, timeout time.Duration) *Context

NewWithTimeout creates a new test context with a given timeout

func (*Context) Check

func (ctx *Context) Check(fn func() error)

Check calls fn and checks result

func (*Context) Cleanup

func (ctx *Context) Cleanup()

Cleanup waits everything to be completed, checks errors and goroutines which haven't ended and tries to cleanup directories

func (*Context) Compile

func (ctx *Context) Compile(pkg string) string

Compile compiles the specified package and returns the executable name.

func (*Context) Dir

func (ctx *Context) Dir(elem ...string) string

Dir creates a subdirectory inside temp joining any number of path elements into a single path and return its absolute path.

func (*Context) File

func (ctx *Context) File(elem ...string) string

File returns a filepath inside a temp directory joining any number of path elements into a single path and returns its absolute path.

func (*Context) Go

func (ctx *Context) Go(fn func() error)

Go runs fn in a goroutine. Call Wait to check the result

type TB

type TB interface {
	Name() string
	Helper()
	Error(args ...interface{})
	Fatal(args ...interface{})
}

TB is a subset of testing.TB methods

Jump to

Keyboard shortcuts

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