testcontext

package
v0.10.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

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

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 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(subs ...string) string

Dir returns a directory path inside temp

func (*Context) File

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

File returns a filepath inside temp

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