testutils

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeValidUUID

func BeValidUUID() types.GomegaMatcher

BeValidUUID returns a gomega matcher that checks validity of a UUID string

func NewJUnitReporter

func NewJUnitReporter() reporters.Reporter

NewJUnitReporter creates a new JUnit compatible reporter that will output to a junit_<node_id>.xml file in each suite's directory.

func RunTestWithTimeout

func RunTestWithTimeout(f func(), d time.Duration)

RunTestWithTimeout runs function f until provided timeout. If the function times out, it will cause the ginkgo test to fail.

Types

type AsyncTestHelper

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

AsyncTestHelper provides synchronization methods to test goroutines. Example:

var (
	asyncHelper testutils.AsyncTestHelper
)

BeforeEach(func() {
	mockMyInterface.EXPECT().MyMethodInGoroutine().Do(asyncHelper.ExpectAndNotifyCallback())
})

AfterEach(func() {
	asyncHelper.WaitWithTimeout(time.Second)
})

func (*AsyncTestHelper) ExpectAndNotifyCallback

func (helper *AsyncTestHelper) ExpectAndNotifyCallback() func(...interface{})

ExpectAndNotifyCallback Adds one to this helper's WaitGroup, and provides a callback that calls Done on it. Should be used for gomock Do calls that trigger via mocked functions executed in a goroutine.

func (*AsyncTestHelper) ExpectAndNotifyCallbackWithName

func (helper *AsyncTestHelper) ExpectAndNotifyCallbackWithName(name string) func(...interface{})

ExpectAndNotifyCallback Adds one to this helper's WaitGroup, and provides a callback that calls Done on it. Should be used for gomock Do calls that trigger via mocked functions executed in a goroutine.

func (*AsyncTestHelper) RegisterCalls

func (helper *AsyncTestHelper) RegisterCalls(calls ...*gomock.Call)

RegisterCalls registers a number of calls to this async helper, so that they are waited for.

func (*AsyncTestHelper) RunTestWithTimeout

func (helper *AsyncTestHelper) RunTestWithTimeout(f func(), d time.Duration)

RunTestWithTimeout runs function f until provided timeout. If the function times out, it will cause the ginkgo test to fail.

func (*AsyncTestHelper) Setup

func (helper *AsyncTestHelper) Setup()

func (*AsyncTestHelper) WaitWithTimeout

func (helper *AsyncTestHelper) WaitWithTimeout(d time.Duration)

WaitWithTimeout waits for this helper's WaitGroup until provided timeout. Should wait for all ExpectAndNotifyCallback callbacks, registered in asynchronous mocks calls

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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