Skip to content

Commit 45a4a20

Browse files
committed
Fix: Update
1 parent 7b1e585 commit 45a4a20

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

dbos/dbos.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ func NewDBOSContext(ctx context.Context, inputConfig Config) (DBOSContext, error
360360
var ws []WorkflowStatus
361361
safeGobRegister(ws, initExecutor.logger)
362362
var si []StepInfo
363+
safeGobRegister(si, initExecutor.logger)
363364
var h workflowHandle[any]
364365
safeGobRegister(h, initExecutor.logger)
365366
var ph workflowPollingHandle[any]

dbos/dbos_test.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -735,22 +735,38 @@ func TestWorkflowHandlerRegistration(t *testing.T) {
735735

736736
require.NotNil(t, ctx)
737737

738-
wf := func(ctx DBOSContext, input string) (string, error) {
739-
return input, nil
738+
childWf := func(ctx DBOSContext, input string) (string, error) {
739+
return "child-" + input, nil
740+
}
741+
742+
wf := func(ctx DBOSContext, input string) (WorkflowHandle[string], error) {
743+
childHandle, err := RunWorkflow(ctx, childWf, input)
744+
if err != nil {
745+
var emptyHandle WorkflowHandle[string]
746+
return emptyHandle, err
747+
}
748+
return childHandle, nil
740749
}
741750

751+
RegisterWorkflow(ctx, childWf)
742752
RegisterWorkflow(ctx, wf)
743753

744754
// Launch a workflow
745755
err = Launch(ctx)
746756
require.NoError(t, err)
747757
defer Shutdown(ctx, 1*time.Minute)
748758

749-
// Run a workflow
750-
handle, err := RunWorkflow(ctx, wf, "test-input")
759+
parentHandle, err := RunWorkflow(ctx, wf, "test-input")
751760
require.NoError(t, err)
752761

753-
result, err := handle.GetResult()
754-
require.NoError(t, err, "failed to get result from workflow")
755-
assert.Equal(t, "test-input", result)
762+
// The result of the parent workflow should itself be a workflow handle
763+
childHandle, err := parentHandle.GetResult()
764+
require.NoError(t, err, "failed to get child handle from parent workflow")
765+
766+
// Now we can use the child handle to get the final result
767+
result, err := childHandle.GetResult()
768+
require.NoError(t, err, "failed to get result from child workflow")
769+
770+
// Assert final child workflow result
771+
assert.Equal(t, "child-test-input", result)
756772
}

0 commit comments

Comments
 (0)