@@ -117,14 +117,22 @@ func TestStandardModeSwitch(t *testing.T) {
117117 t .Run ("successful mode switch" , func (t * testing.T ) {
118118 mockExecutionHelper := NewMockExecutionHelper (t )
119119 mockExecutionHelper .EXPECT ().GetWorkflowExecutionID ().Return ("id" )
120- var timeCallSequence []string
120+ // Node calls may occur on initialization depending on the language.
121+ var donCall1 bool
122+ var nodeCall bool
123+ var donCall2 bool
121124 mockExecutionHelper .EXPECT ().GetNodeTime ().RunAndReturn (func () time.Time {
122- timeCallSequence = append (timeCallSequence , "NODE" )
125+ if donCall1 {
126+ nodeCall = true
127+ }
123128 return time .Now ()
124129 })
125130 // We want to make sure time.Sleep() is called at least twice in DON mode and once in node Mode
126131 mockExecutionHelper .EXPECT ().GetDONTime (mock .Anything ).RunAndReturn (func (ctx context.Context ) (time.Time , error ) {
127- timeCallSequence = append (timeCallSequence , "DON" )
132+ donCall1 = true
133+ if nodeCall {
134+ donCall2 = true
135+ }
128136 return time .Now (), nil
129137 })
130138 mockExecutionHelper .EXPECT ().CallCapability (mock .Anything , mock .Anything ).RunAndReturn (func (ctx context.Context , request * pb.CapabilityRequest ) (* pb.CapabilityResponse , error ) {
@@ -145,35 +153,9 @@ func TestStandardModeSwitch(t *testing.T) {
145153 request := triggerExecuteRequest (t , 0 , & basictrigger.Outputs {CoolOutput : anyTestTriggerValue })
146154 result := executeWithResult [string ](t , m , request , mockExecutionHelper )
147155 require .Equal (t , "test556" , result )
148-
149- // Verify time call sequence is Node --> DON --> Node --> DON
150- phase := 0
151- for i , call := range timeCallSequence {
152- switch phase {
153- case 0 : // Initial time calls are in Node mode
154- if call == "DON" {
155- if i < 1 {
156- t .Fatalf ("Expected at least one Node time call" )
157- }
158- phase = 1
159- }
160- case 1 : // Switched to DON Mode
161- if call == "NODE" {
162- phase = 2
163- }
164- case 2 : // Switched back to NODE mode
165- if call == "DON" {
166- phase = 3
167- }
168- case 3 : // Switched again to DON Mode
169- if call != "DON" {
170- t .Fatalf ("Unexpected call at index %d in final DON phase: %s" , i , call )
171- }
172- }
173- }
174- if phase < 3 {
175- t .Fatalf ("Did not see final DON phase in call sequence" )
176- }
156+ require .True (t , donCall1 )
157+ require .True (t , nodeCall )
158+ require .True (t , donCall2 )
177159 })
178160
179161 t .Run ("node runtime in don mode" , func (t * testing.T ) {
0 commit comments