testutils

package
v0.0.0-...-0ade494 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: AGPL-3.0 Imports: 8 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 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) ExpectAndNotifyCallbackWithNameOnce

func (helper *AsyncTestHelper) ExpectAndNotifyCallbackWithNameOnce(name string) func()

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

Jump to

Keyboard shortcuts

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