Skip to content

Commit 9a7e9b7

Browse files
authored
Implement the registered workflows and activities APIs in testsuite (#1343)
Update TestActivityEnvironment with new APIs so that it implements the ActivityRegistry interface Update TestWorkflowEnvironment with new APIs so that it implements the Registry interface
1 parent 13c2821 commit 9a7e9b7

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

internal/internal_workflow_testsuite.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,22 @@ func (env *testWorkflowEnvironmentImpl) ExecuteChildWorkflow(params executeWorkf
18841884
return env.executeChildWorkflowWithDelay(0, params, callback, startedHandler)
18851885
}
18861886

1887+
func (env *testWorkflowEnvironmentImpl) GetRegisteredWorkflows() []string {
1888+
return env.registry.GetRegisteredWorkflows()
1889+
}
1890+
1891+
func (env *testWorkflowEnvironmentImpl) GetWorkflowFunc(registerName string) (interface{}, bool) {
1892+
return env.registry.GetWorkflowFunc(registerName)
1893+
}
1894+
1895+
func (env *testWorkflowEnvironmentImpl) GetRegisteredActivities() []string {
1896+
return env.registry.GetRegisteredActivities()
1897+
}
1898+
1899+
func (env *testWorkflowEnvironmentImpl) GetActivityFunc(registerName string) (interface{}, bool) {
1900+
return env.registry.GetActivityFunc(registerName)
1901+
}
1902+
18871903
func (env *testWorkflowEnvironmentImpl) executeChildWorkflowWithDelay(delayStart time.Duration, params executeWorkflowParams, callback resultHandler, startedHandler func(r WorkflowExecution, e error)) error {
18881904
childEnv, err := env.newTestWorkflowEnvironmentForChild(&params, callback, startedHandler)
18891905
if err != nil {

internal/workflow_testsuite.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ func (t *TestActivityEnvironment) RegisterActivityWithOptions(a interface{}, opt
141141
t.impl.RegisterActivityWithOptions(a, options)
142142
}
143143

144+
func (t *TestActivityEnvironment) GetRegisteredActivities() []string {
145+
return t.impl.GetRegisteredActivities()
146+
}
147+
148+
func (t *TestActivityEnvironment) GetActivityFunc(registerName string) (interface{}, bool) {
149+
return t.impl.GetActivityFunc(registerName)
150+
}
151+
144152
// ExecuteActivity executes an activity. The tested activity will be executed synchronously in the calling goroutinue.
145153
// Caller should use Value.Get() to extract strong typed result value.
146154
func (t *TestActivityEnvironment) ExecuteActivity(activityFn interface{}, args ...interface{}) (Value, error) {
@@ -206,6 +214,22 @@ func (t *TestWorkflowEnvironment) RegisterActivityWithOptions(a interface{}, opt
206214
t.impl.RegisterActivityWithOptions(a, options)
207215
}
208216

217+
func (t *TestWorkflowEnvironment) GetRegisteredWorkflows() []string {
218+
return t.impl.GetRegisteredWorkflows()
219+
}
220+
221+
func (t *TestWorkflowEnvironment) GetWorkflowFunc(registerName string) (interface{}, bool) {
222+
return t.impl.GetWorkflowFunc(registerName)
223+
}
224+
225+
func (t *TestWorkflowEnvironment) GetRegisteredActivities() []string {
226+
return t.impl.GetRegisteredActivities()
227+
}
228+
229+
func (t *TestWorkflowEnvironment) GetActivityFunc(registerName string) (interface{}, bool) {
230+
return t.impl.GetActivityFunc(registerName)
231+
}
232+
209233
// SetStartTime sets the start time of the workflow. This is optional, default start time will be the wall clock time when
210234
// workflow starts. Start time is the workflow.Now(ctx) time at the beginning of the workflow.
211235
func (t *TestWorkflowEnvironment) SetStartTime(startTime time.Time) {

0 commit comments

Comments
 (0)