@@ -74,10 +74,34 @@ type testWorkflow struct {
74
74
pendingEvents []* history.Event
75
75
}
76
76
77
- type options struct {
78
- TestTimeout time.Duration
79
- Logger log.Logger
80
- Converter converter.Converter
77
+ type WorkflowTester [TResult any ] interface {
78
+ // Now returns the current time of the simulated clock in the tester
79
+ Now () time.Time
80
+
81
+ Execute (args ... interface {})
82
+
83
+ Registry () * workflow.Registry
84
+
85
+ OnActivity (activity interface {}, args ... interface {}) * mock.Call
86
+
87
+ OnSubWorkflow (workflow interface {}, args ... interface {}) * mock.Call
88
+
89
+ SignalWorkflow (signalName string , value interface {})
90
+
91
+ SignalWorkflowInstance (wfi * core.WorkflowInstance , signalName string , value interface {}) error
92
+
93
+ WorkflowFinished () bool
94
+
95
+ WorkflowResult () (TResult , string )
96
+
97
+ // AssertExpectations asserts any assertions set up for mock activities and sub-workflow
98
+ AssertExpectations (t * testing.T )
99
+
100
+ // ScheduleCallback schedules the given callback after the given delay in workflow time (not wall clock).
101
+ ScheduleCallback (delay time.Duration , callback func ())
102
+
103
+ // ListenSubWorkflow registers a handler to be called when a sub-workflow is started.
104
+ ListenSubWorkflow (listener func (instance * core.WorkflowInstance , name string ))
81
105
}
82
106
83
107
type workflowTester [TResult any ] struct {
@@ -130,6 +154,8 @@ type workflowTester[TResult any] struct {
130
154
converter converter.Converter
131
155
}
132
156
157
+ var _ WorkflowTester [any ] = (* workflowTester [any ])(nil )
158
+
133
159
func NewWorkflowTester [TResult any ](wf interface {}, opts ... WorkflowTesterOption ) * workflowTester [TResult ] {
134
160
if err := margs.ReturnTypeMatch [TResult ](wf ); err != nil {
135
161
panic (fmt .Sprintf ("workflow return type does not match: %s" , err ))
0 commit comments