Skip to content

Commit 6d60dac

Browse files
committed
nits
1 parent 9d86f56 commit 6d60dac

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

dbos/workflows_test.go

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ var (
4646
wfClose = WithWorkflow(func(ctx context.Context, in string) (string, error) {
4747
return prefix + in, nil
4848
})
49-
// Workflow for idempotency testing
50-
idempotencyWf = WithWorkflow(idempotencyWorkflow)
51-
idempotencyWfWithStep = WithWorkflow(idempotencyWorkflowWithStep)
5249
)
5350

5451
func simpleWorkflow(ctxt context.Context, input string) (string, error) {
@@ -81,27 +78,6 @@ func incrementCounter(_ context.Context, value int64) (int64, error) {
8178
return idempotencyCounter, nil
8279
}
8380

84-
func idempotencyWorkflow(ctx context.Context, input string) (string, error) {
85-
incrementCounter(ctx, 1)
86-
return input, nil
87-
}
88-
89-
var blockingStepStopEvent *Event
90-
91-
func blockingStep(ctx context.Context, input string) (string, error) {
92-
blockingStepStopEvent.Wait()
93-
return "", nil
94-
}
95-
96-
var idempotencyWorkflowWithStepEvent *Event
97-
98-
func idempotencyWorkflowWithStep(ctx context.Context, input string) (int64, error) {
99-
RunAsStep(ctx, incrementCounter, 1)
100-
idempotencyWorkflowWithStepEvent.Set()
101-
RunAsStep(ctx, blockingStep, input)
102-
return idempotencyCounter, nil
103-
}
104-
10581
// Unified struct that demonstrates both pointer and value receiver methods
10682
type workflowStruct struct{}
10783

@@ -139,7 +115,6 @@ var (
139115
})
140116
)
141117

142-
// TODO: spin into dbos_test.go
143118
func TestAppVersion(t *testing.T) {
144119
if _, err := hex.DecodeString(APP_VERSION); err != nil {
145120
t.Fatalf("APP_VERSION is not a valid hex string: %v", err)
@@ -589,6 +564,32 @@ func TestChildWorkflow(t *testing.T) {
589564
})
590565
}
591566

567+
var (
568+
idempotencyWf = WithWorkflow(idempotencyWorkflow)
569+
idempotencyWfWithStep = WithWorkflow(idempotencyWorkflowWithStep)
570+
)
571+
572+
func idempotencyWorkflow(ctx context.Context, input string) (string, error) {
573+
incrementCounter(ctx, 1)
574+
return input, nil
575+
}
576+
577+
var blockingStepStopEvent *Event
578+
579+
func blockingStep(ctx context.Context, input string) (string, error) {
580+
blockingStepStopEvent.Wait()
581+
return "", nil
582+
}
583+
584+
var idempotencyWorkflowWithStepEvent *Event
585+
586+
func idempotencyWorkflowWithStep(ctx context.Context, input string) (int64, error) {
587+
RunAsStep(ctx, incrementCounter, 1)
588+
idempotencyWorkflowWithStepEvent.Set()
589+
RunAsStep(ctx, blockingStep, input)
590+
return idempotencyCounter, nil
591+
}
592+
592593
func TestWorkflowIdempotency(t *testing.T) {
593594
setupDBOS(t)
594595

@@ -639,9 +640,7 @@ func TestWorkflowIdempotency(t *testing.T) {
639640

640641
func TestWorkflowRecovery(t *testing.T) {
641642
setupDBOS(t)
642-
643643
t.Run("RecoveryResumeWhereItLeftOff", func(t *testing.T) {
644-
645644
// Reset the global counter
646645
idempotencyCounter = 0
647646

@@ -713,7 +712,6 @@ func TestWorkflowRecovery(t *testing.T) {
713712
if result != idempotencyCounter {
714713
t.Fatalf("expected result to be %s, got %s", input, result)
715714
}
716-
717715
})
718716
}
719717

0 commit comments

Comments
 (0)