Skip to content

Commit 604f1f4

Browse files
committed
Return struct instead of interface
Allow accessing internal state in tests
1 parent e895465 commit 604f1f4

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

tester/tester.go

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,6 @@ func (t *testHistoryProvider) GetWorkflowInstanceHistory(ctx context.Context, in
3838
return t.history, nil
3939
}
4040

41-
type WorkflowTester[TResult any] interface {
42-
// Now returns the current time of the simulated clock in the tester
43-
Now() time.Time
44-
45-
Execute(args ...interface{})
46-
47-
Registry() *workflow.Registry
48-
49-
OnActivity(activity interface{}, args ...interface{}) *mock.Call
50-
51-
OnSubWorkflow(workflow interface{}, args ...interface{}) *mock.Call
52-
53-
SignalWorkflow(signalName string, value interface{})
54-
55-
SignalWorkflowInstance(wfi *core.WorkflowInstance, signalName string, value interface{}) error
56-
57-
WorkflowFinished() bool
58-
59-
WorkflowResult() (TResult, string)
60-
61-
// AssertExpectations asserts any assertions set up for mock activities and sub-workflow
62-
AssertExpectations(t *testing.T)
63-
64-
// ScheduleCallback schedules the given callback after the given delay in workflow time (not wall clock).
65-
ScheduleCallback(delay time.Duration, callback func())
66-
67-
// ListenSubWorkflow registers a handler to be called when a sub-workflow is started.
68-
ListenSubWorkflow(listener func(instance *core.WorkflowInstance, name string))
69-
}
70-
7141
type testTimer struct {
7242
// Instance is the workflow instance this timer is for
7343
Instance *core.WorkflowInstance
@@ -161,7 +131,7 @@ func WithTestTimeout(timeout time.Duration) WorkflowTesterOption {
161131
}
162132
}
163133

164-
func NewWorkflowTester[TResult any](wf interface{}, opts ...WorkflowTesterOption) WorkflowTester[TResult] {
134+
func NewWorkflowTester[TResult any](wf interface{}, opts ...WorkflowTesterOption) *workflowTester[TResult] {
165135
if err := margs.ReturnTypeMatch[TResult](wf); err != nil {
166136
panic(fmt.Sprintf("workflow return type does not match: %s", err))
167137
}

0 commit comments

Comments
 (0)