tester

package
v0.0.0-...-e49e9a2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TM_TimeTravel is the default time mode. Time is advanced by directly jumping to the next timer ready to be fired.
	TM_TimeTravel timeMode = iota

	// TM_WallClock prevents time traveling. Timers are only fired when the time has actually passed.
	TM_WallClock
)

Variables

This section is empty.

Functions

func NewWorkflowTester

func NewWorkflowTester[TResult any](wf interface{}, opts ...WorkflowTesterOption) *workflowTester[TResult]

Types

type WorkflowTester

type WorkflowTester[TResult any] interface {
	// Now returns the current time of the simulated clock in the tester
	Now() time.Time

	Execute(ctx context.Context, args ...interface{})

	Registry() *workflow.Registry

	OnActivity(activity workflow.Activity, args ...interface{}) *mock.Call

	OnActivityByName(name string, activity workflow.Activity, args ...interface{}) *mock.Call

	OnSubWorkflow(workflow workflow.Workflow, args ...interface{}) *mock.Call

	OnSubWorkflowByName(name string, workflow workflow.Workflow, args ...interface{}) *mock.Call

	SignalWorkflow(signalName string, value interface{})

	SignalWorkflowInstance(wfi *core.WorkflowInstance, signalName string, value interface{}) error

	WorkflowFinished() bool

	WorkflowResult() (TResult, error)

	// AssertExpectations asserts any assertions set up for mock activities and sub-workflow
	AssertExpectations(t *testing.T)

	// ScheduleCallback schedules the given callback after the given delay in workflow time (not wall clock).
	ScheduleCallback(delay time.Duration, callback func())

	// ListenSubWorkflow registers a handler to be called when a sub-workflow is started.
	ListenSubWorkflow(listener func(instance *core.WorkflowInstance, name string))
}

type WorkflowTesterOption

type WorkflowTesterOption func(*options)

func WithConverter

func WithConverter(converter converter.Converter) WorkflowTesterOption

func WithLogger

func WithLogger(logger *slog.Logger) WorkflowTesterOption

func WithTestTimeout

func WithTestTimeout(timeout time.Duration) WorkflowTesterOption

Jump to

Keyboard shortcuts

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