@@ -512,6 +512,52 @@ func TestSteps(t *testing.T) {
512512 expectedStepName2 := runtime .FuncForPC (reflect .ValueOf (step2 ).Pointer ()).Name ()
513513 assert .Equal (t , expectedStepName2 , s2 .StepName , "expected step name to match runtime function name" )
514514 })
515+
516+ t .Run ("customStepNames" , func (t * testing.T ) {
517+ // Create a workflow that uses custom step names
518+ customNameWorkflow := func (dbosCtx DBOSContext , input string ) (string , error ) {
519+ // Run a step with a custom name
520+ result1 , err := RunAsStep (dbosCtx , func (ctx context.Context ) (string , error ) {
521+ return "custom-step-1-result" , nil
522+ }, WithStepName ("MyCustomStep1" ))
523+ if err != nil {
524+ return "" , err
525+ }
526+
527+ // Run another step with a different custom name
528+ result2 , err := RunAsStep (dbosCtx , func (ctx context.Context ) (string , error ) {
529+ return "custom-step-2-result" , nil
530+ }, WithStepName ("MyCustomStep2" ))
531+ if err != nil {
532+ return "" , err
533+ }
534+
535+ return result1 + "-" + result2 , nil
536+ }
537+
538+ RegisterWorkflow (dbosCtx , customNameWorkflow )
539+
540+ // Execute the workflow
541+ handle , err := RunAsWorkflow (dbosCtx , customNameWorkflow , "test-input" )
542+ require .NoError (t , err , "failed to run workflow with custom step names" )
543+
544+ result , err := handle .GetResult ()
545+ require .NoError (t , err , "failed to get result from workflow with custom step names" )
546+ assert .Equal (t , "custom-step-1-result-custom-step-2-result" , result )
547+
548+ // Verify the custom step names were recorded
549+ steps , err := dbosCtx .(* dbosContext ).systemDB .getWorkflowSteps (dbosCtx , handle .GetWorkflowID ())
550+ require .NoError (t , err , "failed to get workflow steps" )
551+ require .Len (t , steps , 2 , "expected 2 steps" )
552+
553+ // Check that the first step has the custom name
554+ assert .Equal (t , "MyCustomStep1" , steps [0 ].StepName , "expected first step to have custom name" )
555+ assert .Equal (t , 0 , steps [0 ].StepID )
556+
557+ // Check that the second step has the custom name
558+ assert .Equal (t , "MyCustomStep2" , steps [1 ].StepName , "expected second step to have custom name" )
559+ assert .Equal (t , 1 , steps [1 ].StepID )
560+ })
515561}
516562
517563func TestChildWorkflow (t * testing.T ) {
0 commit comments