@@ -23,14 +23,14 @@ type backendTest struct {
23
23
name string
24
24
options []backend.BackendOption
25
25
withoutCache bool // If set, test will only be run when the cache is disabled
26
- f func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend )
26
+ f func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend )
27
27
}
28
28
29
29
func EndToEndBackendTest (t * testing.T , setup func (options ... backend.BackendOption ) TestBackend , teardown func (b TestBackend )) {
30
30
tests := []backendTest {
31
31
{
32
32
name : "SimpleWorkflow" ,
33
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
33
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
34
34
wf := func (ctx workflow.Context , msg string ) (string , error ) {
35
35
return msg + " world" , nil
36
36
}
@@ -44,7 +44,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
44
44
},
45
45
{
46
46
name : "SimpleWorkflow_ExpectedHistory" ,
47
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
47
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
48
48
wf := func (ctx workflow.Context , msg string ) (string , error ) {
49
49
return msg + " world" , nil
50
50
}
@@ -66,7 +66,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
66
66
},
67
67
{
68
68
name : "UnregisteredWorkflow_Errors" ,
69
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
69
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
70
70
wf := func (ctx workflow.Context , msg string ) (string , error ) {
71
71
return msg + " world" , nil
72
72
}
@@ -80,7 +80,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
80
80
},
81
81
{
82
82
name : "WorkflowArgumentMismatch" ,
83
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
83
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
84
84
wf := func (ctx workflow.Context , p1 int ) (int , error ) {
85
85
return 42 , nil
86
86
}
@@ -96,7 +96,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
96
96
},
97
97
{
98
98
name : "UnregisteredActivity_Errors" ,
99
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
99
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
100
100
a := func (context.Context ) error { return nil }
101
101
wf := func (ctx workflow.Context ) (int , error ) {
102
102
return workflow .ExecuteActivity [int ](ctx , workflow.ActivityOptions {
@@ -115,7 +115,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
115
115
},
116
116
{
117
117
name : "ActivityArgumentMismatch" ,
118
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
118
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
119
119
a := func (context.Context , int , int ) error { return nil }
120
120
wf := func (ctx workflow.Context ) (int , error ) {
121
121
return workflow .ExecuteActivity [int ](ctx , workflow.ActivityOptions {
@@ -134,7 +134,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
134
134
},
135
135
{
136
136
name : "SideEffect_Simple" ,
137
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
137
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
138
138
i := 2
139
139
wf := func (ctx workflow.Context ) (int , error ) {
140
140
r1 , _ := workflow .SideEffect (ctx , func (ctx workflow.Context ) int {
@@ -163,7 +163,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
163
163
},
164
164
{
165
165
name : "Signal_after_completion" ,
166
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
166
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
167
167
wf := func (ctx workflow.Context ) error {
168
168
return nil
169
169
}
@@ -180,7 +180,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
180
180
},
181
181
{
182
182
name : "SubWorkflow_Simple" ,
183
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
183
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
184
184
swf := func (ctx workflow.Context , i int ) (int , error ) {
185
185
return i * 2 , nil
186
186
}
@@ -203,7 +203,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
203
203
},
204
204
{
205
205
name : "SubWorkflow_PropagateCancellation" ,
206
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
206
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
207
207
canceled := int32 (0 )
208
208
209
209
swf := func (ctx workflow.Context , i int ) (int , error ) {
@@ -267,7 +267,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
267
267
},
268
268
{
269
269
name : "SubWorkflow_CancelBeforeStarting" ,
270
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
270
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
271
271
swInstanceID := "subworkflow"
272
272
273
273
swfrun := 0
@@ -313,7 +313,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
313
313
},
314
314
{
315
315
name : "SubWorkflow_Signal" ,
316
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
316
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
317
317
swf := func (ctx workflow.Context , i int ) (int , error ) {
318
318
workflow .NewSignalChannel [string ](ctx , "signal" ).Receive (ctx )
319
319
@@ -347,7 +347,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
347
347
},
348
348
{
349
349
name : "SubWorkflow_Signal_BeforeStarting" ,
350
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
350
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
351
351
wf := func (ctx workflow.Context ) (int , error ) {
352
352
id , _ := workflow .SideEffect (ctx , func (ctx workflow.Context ) string {
353
353
id := uuid .New ().String ()
@@ -371,7 +371,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
371
371
},
372
372
{
373
373
name : "Timer_CancelWorkflowInstance" ,
374
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
374
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
375
375
a := func (ctx context.Context ) error {
376
376
return nil
377
377
}
@@ -398,7 +398,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
398
398
},
399
399
{
400
400
name : "Timer_CancelBeforeStarting" ,
401
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
401
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
402
402
a := func (ctx context.Context ) error {
403
403
return nil
404
404
}
@@ -441,7 +441,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
441
441
},
442
442
{
443
443
name : "Timer_CancelTwice" ,
444
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
444
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
445
445
a := func (ctx context.Context ) error {
446
446
return nil
447
447
}
@@ -484,7 +484,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
484
484
},
485
485
{
486
486
name : "Timer_CancelBeforeFiringRemovesFutureEvent" ,
487
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
487
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
488
488
a := func (ctx context.Context ) error {
489
489
return nil
490
490
}
@@ -523,7 +523,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
523
523
{
524
524
name : "NonDeterminism" ,
525
525
withoutCache : true ,
526
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
526
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
527
527
i := 0
528
528
wf := func (ctx workflow.Context ) (int , error ) {
529
529
var r int
@@ -553,7 +553,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
553
553
},
554
554
{
555
555
name : "RemoveWorkflowInstance" ,
556
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
556
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
557
557
wf := func (ctx workflow.Context , msg string ) (string , error ) {
558
558
return msg + " world" , nil
559
559
}
@@ -576,7 +576,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
576
576
{
577
577
name : "ContextPropagation" ,
578
578
options : []backend.BackendOption {backend .WithContextPropagator (& testContextPropagator {})},
579
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
579
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
580
580
a := func (ctx context.Context ) (int , error ) {
581
581
d := myValues (ctx )
582
582
return d .Count , nil
@@ -610,7 +610,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
610
610
},
611
611
{
612
612
name : "ContinueAsNew" ,
613
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
613
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
614
614
wf := func (ctx workflow.Context , run int ) (int , error ) {
615
615
run = run + 1
616
616
if run < 3 {
@@ -634,7 +634,7 @@ func EndToEndBackendTest(t *testing.T, setup func(options ...backend.BackendOpti
634
634
},
635
635
{
636
636
name : "ContinueAsNew_Subworkflow" ,
637
- f : func (t * testing.T , ctx context.Context , c client.Client , w * worker.Worker , b TestBackend ) {
637
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
638
638
swf := func (ctx workflow.Context , run int ) (int , error ) {
639
639
l := workflow .Logger (ctx )
640
640
@@ -740,7 +740,7 @@ func register(t *testing.T, ctx context.Context, w *worker.Worker, workflows []i
740
740
require .NoError (t , err )
741
741
}
742
742
743
- func runWorkflow (t * testing.T , ctx context.Context , c client.Client , wf interface {}, inputs ... interface {}) * workflow.Instance {
743
+ func runWorkflow (t * testing.T , ctx context.Context , c * client.Client , wf interface {}, inputs ... interface {}) * workflow.Instance {
744
744
instance , err := c .CreateWorkflowInstance (ctx , client.WorkflowInstanceOptions {
745
745
InstanceID : uuid .NewString (),
746
746
}, wf , inputs ... )
@@ -749,7 +749,7 @@ func runWorkflow(t *testing.T, ctx context.Context, c client.Client, wf interfac
749
749
return instance
750
750
}
751
751
752
- func runWorkflowWithResult [T any ](t * testing.T , ctx context.Context , c client.Client , wf interface {}, inputs ... interface {}) (T , error ) {
752
+ func runWorkflowWithResult [T any ](t * testing.T , ctx context.Context , c * client.Client , wf interface {}, inputs ... interface {}) (T , error ) {
753
753
instance := runWorkflow (t , ctx , c , wf , inputs ... )
754
754
return client .GetWorkflowResult [T ](ctx , c , instance , time .Second * 10 )
755
755
}
0 commit comments