testutil

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyContext

func ApplyContext(ctx context.Context, fns ...SetContextFn) context.Context

ApplyContext applies given contextFns to context.

func CleanOutput

func CleanOutput(s string) string

CleanOutput takes a string and strips extra characters that are not consistent across platforms.

func CommandPath

func CommandPath(s string, p ...string) string

CommandPath takes a path to a command and returns a corrected path for the operating system this is running on.

func CompareError

func CompareError(err error, expected bool, t *testing.T)

CompareError ensures that the provided err is expected

func NewContext

func NewContext(fns ...SetContextFn) (ctx context.Context)

NewContext instantiates new todo context and applies given contextFns to it.

func RandomPorts

func RandomPorts(p []int) (err error)

RandomPorts generates len(p) random ports and assigns them to elements of p.

func TempDir

func TempDir(t *testing.T) (tmpDir string, remove func())

TempDir provides a test with a temporary directory (under os.TempDir()) returning the absolute path to the directory and a remove() function that should be deferred immediately after calling TempDir(t) to recursively delete the contents of the directory.

Types

type SetContextFn

type SetContextFn func(context.Context) context.Context

SetContextFn take context and return new context

func ContextWithNamespace

func ContextWithNamespace(namespace string) SetContextFn

ContextWithNamespace returns new contextFn with namespace added.

func ContextWithStore

func ContextWithStore(store store.Store) SetContextFn

ContextWithStore returns new contextFn with given store value applied to context.

Jump to

Keyboard shortcuts

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