testutil

package
v0.0.0-...-591e9e7 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MkTempDir

func MkTempDir(t *testing.T) (string, func())

func WithTempDir

func WithTempDir(t *testing.T, f func(path string))

Types

type CallCounter

type CallCounter struct {
	// contains filtered or unexported fields
}

CallCounter provides a mechanism for one goroutine to increment a counter, usually once per some method call, and for other goroutines to block until the counter reaches some expected value.

func NewCallCounter

func NewCallCounter() *CallCounter

func (*CallCounter) Incr

func (c *CallCounter) Incr()

Incr increments the call counter and unblocks any waiters whose expected call counter is now met. It is safe to this method on the zero value since both test and non-test code is expected to call this. This method is safe to be used from multiple goroutines.

func (*CallCounter) Wait

func (c *CallCounter) Wait(expected int)

Wait blocks the calling goroutine until the callCounter reaches atleast expected number of calls. Since this method is only expected to be called by test code, it will panic if called on the zero value as way to alert the user that they forgot to initialize the callCounter. This method is safe to be called from multiple goroutines.

type TempFile

type TempFile struct {
	*os.File
}

func MkTempFile

func MkTempFile(t *testing.T) *TempFile

func MkTempFileWithDir

func MkTempFileWithDir(dir string, t *testing.T) *TempFile

func (*TempFile) Remove

func (f *TempFile) Remove()

Jump to

Keyboard shortcuts

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