Skip to content

Commit 0785e35

Browse files
authored
rename test handles to avoid name conflict (#143)
1 parent baa368d commit 0785e35

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

internal_workflow_testsuite.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const (
4646
)
4747

4848
type (
49-
timerHandle struct {
49+
testTimerHandle struct {
5050
callback resultHandler
5151
timer *clock.Timer
5252
wallTimer *clock.Timer
@@ -56,12 +56,12 @@ type (
5656
timerID int
5757
}
5858

59-
activityHandle struct {
59+
testActivityHandle struct {
6060
callback resultHandler
6161
activityType string
6262
}
6363

64-
callbackHandle struct {
64+
testCallbackHandle struct {
6565
callback func()
6666
startDecisionTask bool // start a new decision task after callback() is handled.
6767
}
@@ -96,8 +96,8 @@ type (
9696
signalHandler func(name string, input []byte)
9797

9898
locker *sync.Mutex
99-
scheduledActivities map[string]*activityHandle
100-
scheduledTimers map[string]*timerHandle
99+
scheduledActivities map[string]*testActivityHandle
100+
scheduledTimers map[string]*testTimerHandle
101101
runningActivityCount atomic.Int32
102102

103103
onActivityStartedListener func(activityInfo *ActivityInfo, ctx context.Context, args EncodedValues)
@@ -108,7 +108,7 @@ type (
108108
onTimerFiredListener func(timerID string)
109109
onTimerCancelledListener func(timerID string)
110110

111-
callbackChannel chan callbackHandle
111+
callbackChannel chan testCallbackHandle
112112
testTimeout time.Duration
113113
isTestCompleted bool
114114
testResult EncodedValue
@@ -137,9 +137,9 @@ func newTestWorkflowEnvironmentImpl(s *WorkflowTestSuite) *testWorkflowEnvironme
137137
},
138138

139139
locker: &sync.Mutex{},
140-
scheduledActivities: make(map[string]*activityHandle),
141-
scheduledTimers: make(map[string]*timerHandle),
142-
callbackChannel: make(chan callbackHandle, 1000),
140+
scheduledActivities: make(map[string]*testActivityHandle),
141+
scheduledTimers: make(map[string]*testTimerHandle),
142+
callbackChannel: make(chan testCallbackHandle, 1000),
143143
testTimeout: time.Second * 3,
144144
}
145145

@@ -345,7 +345,7 @@ func (env *testWorkflowEnvironmentImpl) registerDelayedCallback(f func(), delayD
345345
}, true)
346346
}
347347

348-
func (env *testWorkflowEnvironmentImpl) processCallback(c callbackHandle) {
348+
func (env *testWorkflowEnvironmentImpl) processCallback(c testCallbackHandle) {
349349
c.callback()
350350
if c.startDecisionTask && !env.isTestCompleted {
351351
env.workflowDef.OnDecisionTaskStarted() // this will execute dispatcher
@@ -358,7 +358,7 @@ func (env *testWorkflowEnvironmentImpl) autoFireNextTimer() bool {
358358
}
359359

360360
// find next timer
361-
var nextTimer *timerHandle
361+
var nextTimer *testTimerHandle
362362
for _, t := range env.scheduledTimers {
363363
if nextTimer == nil {
364364
nextTimer = t
@@ -369,7 +369,7 @@ func (env *testWorkflowEnvironmentImpl) autoFireNextTimer() bool {
369369
}
370370

371371
// function to fire timer
372-
fireTimer := func(th *timerHandle) {
372+
fireTimer := func(th *testTimerHandle) {
373373
skipDuration := th.mockTimeToFire.Sub(env.mockClock.Now())
374374
env.logger.Debug("Auto fire timer",
375375
zap.Int(tagTimerID, th.timerID),
@@ -421,7 +421,7 @@ func (env *testWorkflowEnvironmentImpl) autoFireNextTimer() bool {
421421
}
422422

423423
func (env *testWorkflowEnvironmentImpl) postCallback(cb func(), startDecisionTask bool) {
424-
env.callbackChannel <- callbackHandle{callback: cb, startDecisionTask: startDecisionTask}
424+
env.callbackChannel <- testCallbackHandle{callback: cb, startDecisionTask: startDecisionTask}
425425
}
426426

427427
func (env *testWorkflowEnvironmentImpl) RequestCancelActivity(activityID string) {
@@ -523,7 +523,7 @@ func (env *testWorkflowEnvironmentImpl) ExecuteActivity(parameters executeActivi
523523
)
524524

525525
taskHandler := env.newTestActivityTaskHandler(parameters.TaskListName)
526-
activityHandle := &activityHandle{callback: callback, activityType: parameters.ActivityType.Name}
526+
activityHandle := &testActivityHandle{callback: callback, activityType: parameters.ActivityType.Name}
527527

528528
// locker is needed to prevent race condition between dispatcher loop goroutinue and activity worker goroutinues.
529529
// The activity workers could call into Heartbeat which by default is mocked in this test suite. The mock needs to
@@ -796,7 +796,7 @@ func (env *testWorkflowEnvironmentImpl) NewTimer(d time.Duration, callback resul
796796
}
797797
}, true)
798798
})
799-
env.scheduledTimers[timerInfo.timerID] = &timerHandle{
799+
env.scheduledTimers[timerInfo.timerID] = &testTimerHandle{
800800
callback: callback,
801801
timer: timer,
802802
mockTimeToFire: env.mockClock.Now().Add(d),

0 commit comments

Comments
 (0)