Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestDispatcher ¶
TestDispatcher runs the common Dispatcher conformance tests. Each Dispatcher implementation should call this from its own package test, passing a SetupFunc.
func WithSyncTest ¶
WithSyncTest wraps a test function with synctest.Test, recovering from deadlock panics and converting them to test failures, allowing subsequent tests to continue.
This prevents a single deadlock bug from stopping the entire test suite. The test will still fail, but with a clear error message, and other tests will run normally.
Usage:
t.Run("test description", WithSyncTest(func(t *testing.T) {
// Your synctest code here
}))
Types ¶
type SetupFunc ¶
type SetupFunc func(t *testing.T) (task.Dispatcher, *TestHelper)
SetupFunc creates a fresh Dispatcher and TestHelper for a single test case. It is called inside a synctest bubble and may register cleanups via t.Cleanup.
type TestHelper ¶
type TestHelper struct {
// Start is the initial time of the test dispatcher.
Start time.Time
// AdvanceToFunc moves time forward to the given absolute time and ensures all tasks up to that point execute.
// Returns an error if a dispatched function panicked (for eventloop-style dispatchers).
AdvanceToFunc func(to time.Time) error
}
TestHelper provides test-specific time control for Dispatcher conformance tests.