Documentation
¶
Overview ¶
Package testsupport contains helpers shared by worker-utils tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunWithWait ¶
func RunWithWait( ctx context.Context, cancel context.CancelFunc, run func(context.Context) error, wait func(context.Context) error, ) (runErr, waitErr error)
RunWithWait runs a worker and waits for its mock server to finish before returning. The waiter cancels the worker when its work completes; if the worker fails first, cancellation releases the waiter. Returning both errors lets callers report failures from the test goroutine rather than a helper goroutine.
func WaitForTrackedCallback ¶
func WaitForTrackedCallback( ctx context.Context, wait func(context.Context) error, callbacks *CallbackGroup, ) error
WaitForTrackedCallback preserves the wait error while ensuring a tracked asynchronous callback and its waiter have finished before cleanup proceeds. The second wait is needed only if the callback started; this avoids blocking when worker startup fails before ConnectOnce launches it.
Types ¶
type CallbackGroup ¶
type CallbackGroup struct {
// contains filtered or unexported fields
}
CallbackGroup tracks asynchronous test callbacks and prevents callbacks scheduled after teardown starts from running against cleaned-up resources.
func NewCallbackGroup ¶
func NewCallbackGroup() *CallbackGroup
NewCallbackGroup creates a tracker with no callbacks in flight.
func (*CallbackGroup) Run ¶
func (g *CallbackGroup) Run(callback func() error) error
Run executes callback unless teardown has started. StopAndWait prevents new callbacks from starting and joins callbacks already in flight.
func (*CallbackGroup) StopAndWait ¶
func (g *CallbackGroup) StopAndWait() bool
StopAndWait prevents further callbacks from starting and waits for callbacks already in flight. It reports whether a callback started before teardown.