tasktest

package
v0.0.0-...-e471764 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestDispatcher

func TestDispatcher(t *testing.T, setup SetupFunc)

TestDispatcher runs the common Dispatcher conformance tests. Each Dispatcher implementation should call this from its own package test, passing a SetupFunc.

func WithSyncTest

func WithSyncTest(f func(t *testing.T)) func(t *testing.T)

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.

func (*TestHelper) AdvanceTo

func (h *TestHelper) AdvanceTo(to time.Time) error

Jump to

Keyboard shortcuts

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