@@ -18,6 +18,7 @@ import (
18
18
"github.com/cschleiden/go-workflows/internal/command"
19
19
"github.com/cschleiden/go-workflows/internal/fn"
20
20
"github.com/cschleiden/go-workflows/internal/sync"
21
+ "github.com/cschleiden/go-workflows/registry"
21
22
wf "github.com/cschleiden/go-workflows/workflow"
22
23
"github.com/google/uuid"
23
24
"github.com/stretchr/testify/require"
@@ -32,7 +33,7 @@ func (t *testHistoryProvider) GetWorkflowInstanceHistory(ctx context.Context, in
32
33
return t .history , nil
33
34
}
34
35
35
- func newExecutor (r * Registry , i * core.WorkflowInstance , historyProvider WorkflowHistoryProvider ) (* executor , error ) {
36
+ func newExecutor (r * registry. Registry , i * core.WorkflowInstance , historyProvider WorkflowHistoryProvider ) (* executor , error ) {
36
37
logger := slog .Default ()
37
38
tracer := trace .NewNoopTracerProvider ().Tracer ("test" )
38
39
@@ -49,11 +50,11 @@ func activity1(ctx context.Context, r int) (int, error) {
49
50
func Test_Executor (t * testing.T ) {
50
51
tests := []struct {
51
52
name string
52
- f func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider )
53
+ f func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider )
53
54
}{
54
55
{
55
56
name : "Simple_workflow_to_completion" ,
56
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
57
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
57
58
workflowHits := 0
58
59
wf := func (ctx sync.Context ) error {
59
60
workflowHits ++
@@ -75,7 +76,7 @@ func Test_Executor(t *testing.T) {
75
76
},
76
77
{
77
78
name : "Workflow with activity command" ,
78
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
79
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
79
80
workflowActivityHit := 0
80
81
workflowWithActivity := func (ctx sync.Context ) error {
81
82
workflowActivityHit ++
@@ -121,7 +122,7 @@ func Test_Executor(t *testing.T) {
121
122
},
122
123
{
123
124
name : "Workflow with activity replay" ,
124
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
125
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
125
126
workflowActivityHit := 0
126
127
workflowWithActivity := func (ctx sync.Context ) error {
127
128
workflowActivityHit ++
@@ -186,7 +187,7 @@ func Test_Executor(t *testing.T) {
186
187
},
187
188
{
188
189
name : "Workflow with new events" ,
189
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
190
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
190
191
workflowActivityHit := 0
191
192
workflowWithActivity := func (ctx sync.Context ) error {
192
193
workflowActivityHit ++
@@ -264,7 +265,7 @@ func Test_Executor(t *testing.T) {
264
265
},
265
266
{
266
267
name : "Workflow with selector" ,
267
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
268
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
268
269
var workflowWithSelectorHits int
269
270
270
271
workflowWithSelector := func (ctx sync.Context ) error {
@@ -320,7 +321,7 @@ func Test_Executor(t *testing.T) {
320
321
},
321
322
{
322
323
name : "Workflow with timer" ,
323
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
324
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
324
325
workflowTimerHits := 0
325
326
326
327
workflowWithTimer := func (ctx sync.Context ) error {
@@ -366,7 +367,7 @@ func Test_Executor(t *testing.T) {
366
367
},
367
368
{
368
369
name : "Cancel timer multiple times" ,
369
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
370
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
370
371
workflowWithTimer := func (ctx sync.Context ) error {
371
372
tctx , cancel := wf .WithCancel (ctx )
372
373
@@ -402,7 +403,7 @@ func Test_Executor(t *testing.T) {
402
403
},
403
404
{
404
405
name : "Workflow with signal" ,
405
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
406
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
406
407
workflowSignalHits := 0
407
408
408
409
workflowWithSignal := func (ctx sync.Context ) error {
@@ -453,7 +454,7 @@ func Test_Executor(t *testing.T) {
453
454
},
454
455
{
455
456
name : "Completes workflow on unhandled error" ,
456
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
457
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
457
458
workflowPanic := func (ctx sync.Context ) error {
458
459
panic ("wf error" )
459
460
}
@@ -487,7 +488,7 @@ func Test_Executor(t *testing.T) {
487
488
},
488
489
{
489
490
name : "Schedule subworkflow" ,
490
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
491
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
491
492
subworkflow := func (ctx wf.Context ) error {
492
493
return nil
493
494
}
@@ -515,7 +516,7 @@ func Test_Executor(t *testing.T) {
515
516
},
516
517
{
517
518
name : "Schedule and cancel subworkflow" ,
518
- f : func (t * testing.T , r * Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
519
+ f : func (t * testing.T , r * registry. Registry , e * executor , i * core.WorkflowInstance , hp * testHistoryProvider ) {
519
520
subworkflow := func (ctx wf.Context ) error {
520
521
return nil
521
522
}
@@ -583,7 +584,7 @@ func Test_Executor(t *testing.T) {
583
584
584
585
for _ , tt := range tests {
585
586
t .Run (tt .name , func (t * testing.T ) {
586
- r := NewRegistry ()
587
+ r := registry . New ()
587
588
588
589
i := core .NewWorkflowInstance (uuid .NewString (), "" )
589
590
hp := & testHistoryProvider {}
0 commit comments