@@ -11,6 +11,7 @@ import (
11
11
"github.com/cschleiden/go-workflows/client"
12
12
"github.com/cschleiden/go-workflows/internal/core"
13
13
"github.com/cschleiden/go-workflows/internal/history"
14
+ internalwf "github.com/cschleiden/go-workflows/internal/workflow"
14
15
"github.com/cschleiden/go-workflows/worker"
15
16
"github.com/cschleiden/go-workflows/workflow"
16
17
"github.com/google/uuid"
@@ -364,30 +365,60 @@ func EndToEndBackendTest(t *testing.T, setup func() TestBackend, teardown func(b
364
365
},
365
366
}
366
367
367
- for _ , tt := range tests {
368
- t .Run (tt .name , func (t * testing.T ) {
369
- b := setup ()
370
- ctx := context .Background ()
371
- ctx , cancel := context .WithCancel (ctx )
368
+ run := func (suffix string , workerOptions * worker.Options ) {
369
+ for _ , tt := range tests {
370
+ t .Run (tt .name + suffix , func (t * testing.T ) {
371
+ b := setup ()
372
+ ctx := context .Background ()
373
+ ctx , cancel := context .WithCancel (ctx )
372
374
373
- c := client .New (b )
374
- w := worker .New (b , & worker . DefaultWorkerOptions )
375
+ c := client .New (b )
376
+ w := worker .New (b , workerOptions )
375
377
376
- t .Cleanup (func () {
377
- cancel ()
378
- if err := w .WaitForCompletion (); err != nil {
379
- log .Println ("Worker did not stop in time" )
380
- t .FailNow ()
381
- }
378
+ t .Cleanup (func () {
379
+ cancel ()
380
+ if err := w .WaitForCompletion (); err != nil {
381
+ log .Println ("Worker did not stop in time" )
382
+ t .FailNow ()
383
+ }
382
384
383
- if teardown != nil {
384
- teardown (b )
385
- }
386
- })
385
+ if teardown != nil {
386
+ teardown (b )
387
+ }
388
+ })
387
389
388
- tt .f (t , ctx , c , w , b )
389
- })
390
+ tt .f (t , ctx , c , w , b )
391
+ })
392
+ }
390
393
}
394
+
395
+ options := worker .DefaultWorkerOptions
396
+
397
+ // Run with cache
398
+ run ("" , & options )
399
+
400
+ // Disable cache for this execution
401
+ options .WorkflowExecutorCache = & noopWorkflowExecutorCache {}
402
+ run ("_without_cache" , & options )
403
+ }
404
+
405
+ type noopWorkflowExecutorCache struct {
406
+ }
407
+
408
+ var _ internalwf.ExecutorCache = (* noopWorkflowExecutorCache )(nil )
409
+
410
+ // Get implements workflow.ExecutorCache
411
+ func (* noopWorkflowExecutorCache ) Get (ctx context.Context , instance * core.WorkflowInstance ) (internalwf.WorkflowExecutor , bool , error ) {
412
+ return nil , false , nil
413
+ }
414
+
415
+ // StartEviction implements workflow.ExecutorCache
416
+ func (* noopWorkflowExecutorCache ) StartEviction (ctx context.Context ) {
417
+ }
418
+
419
+ // Store implements workflow.ExecutorCache
420
+ func (* noopWorkflowExecutorCache ) Store (ctx context.Context , instance * core.WorkflowInstance , workflow internalwf.WorkflowExecutor ) error {
421
+ return nil
391
422
}
392
423
393
424
func register (t * testing.T , ctx context.Context , w worker.Worker , workflows []interface {}, activities []interface {}) {
0 commit comments