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](workflow workflow.Workflow, 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 executes the workflow under test with the given inputs. Execute(ctx context.Context, args ...interface{}) // Registry returns the registry used by the tester. Registry() *registry.Registry // ActivityMock returns the mock instance that's used for activities. In most cases, OnActivity or OnActivityByName // should be used, but sometimes it's necessary to access the mock directly. For instance, to ensure // a certain activity is not called at all ActivityMock() *mock.Mock // OnActivity registers a mock activity. OnActivity(activity workflow.Activity, args ...interface{}) *mock.Call // OnActivityByName registers a mock activity with the given name. OnActivityByName(name string, activity workflow.Activity, args ...interface{}) *mock.Call // OnSubworkflow registers a mock sub-workflow. OnSubWorkflow(workflow workflow.Workflow, args ...interface{}) *mock.Call // OnSubWorkflowByName registers a mock sub-workflow with the given name. OnSubWorkflowByName(name string, workflow workflow.Workflow, args ...interface{}) *mock.Call // SignalWorkflow signals the workflow under test with the given signal name and value. SignalWorkflow(signalName string, value interface{}) // SignalWorkflowInstance signals the given workflow instance with the given signal name and value. SignalWorkflowInstance(wfi *core.WorkflowInstance, signalName string, value interface{}) error // WorkflowFinished returns true if the workflow under test is finished. WorkflowFinished() bool // WorkflowResult returns the result of the workflow under test. If the workflow is not finished yet, this will // error. 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 listener that is called whenever a sub-workflow is started. The listener is called // with the workflow instance of the sub-workflow and the name of the sub-workflow. ListenSubWorkflow(listener func(instance *core.WorkflowInstance, name string)) }
type WorkflowTesterOption ¶ added in v0.4.0
type WorkflowTesterOption func(*options)
func WithContextPropagator ¶ added in v0.14.0
func WithContextPropagator(prop workflow.ContextPropagator) WorkflowTesterOption
func WithConverter ¶ added in v0.9.0
func WithConverter(converter converter.Converter) WorkflowTesterOption
func WithLogger ¶ added in v0.4.0
func WithLogger(logger *slog.Logger) WorkflowTesterOption
func WithTestTimeout ¶ added in v0.4.0
func WithTestTimeout(timeout time.Duration) WorkflowTesterOption
Click to show internal directories.
Click to hide internal directories.