@@ -60,6 +60,16 @@ func TestCLIWorkflow(t *testing.T) {
6060 os .Chdir (originalDir )
6161 })
6262
63+ t .Run ("ResetDatabase" , func (t * testing.T ) {
64+ cmd := exec .Command (cliPath , "reset" , "-y" )
65+ cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL ())
66+
67+ output , err := cmd .CombinedOutput ()
68+ require .NoError (t , err , "Reset database command failed: %s" , string (output ))
69+
70+ assert .Contains (t , string (output ), "System database has been reset successfully" , "Output should confirm database reset" )
71+ })
72+
6373 t .Run ("ProjectInitialization" , func (t * testing.T ) {
6474 testProjectInitialization (t , cliPath )
6575 })
@@ -284,12 +294,6 @@ func testListWorkflows(t *testing.T, cliPath string) {
284294 args : []string {"workflow" , "list" , "--status" , "ERROR" },
285295 checkStatus : dbos .WorkflowStatusError ,
286296 },
287- {
288- name : "StatusFilterEnqueued" ,
289- args : []string {"workflow" , "list" , "--status" , "ENQUEUED" },
290- checkStatus : dbos .WorkflowStatusEnqueued ,
291- minCount : 10 , // We expect at least 10 enqueued workflows from QueueWorkflow
292- },
293297 {
294298 name : "StatusFilterPending" ,
295299 args : []string {"workflow" , "list" , "--status" , "PENDING" },
@@ -564,6 +568,24 @@ func testForkWorkflow(t *testing.T, cliPath string) {
564568 assert .Equal (t , "ENQUEUED" , string (forkedStatus .Status ), "Forked workflow should be enqueued" )
565569 assert .Equal (t , dbosInternalQueueName , forkedStatus .QueueName , "Should be on internal queue" )
566570 })
571+
572+ t .Run ("ForkWorkflowFromNegativeStep" , func (t * testing.T ) {
573+ // Test fork with invalid step number (0 should be converted to 1)
574+ cmd := exec .Command (cliPath , "workflow" , "fork" , workflowID , "--step" , "-1" )
575+ cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL ())
576+
577+ output , err := cmd .CombinedOutput ()
578+ require .NoError (t , err , "Fork workflow from step command failed: %s" , string (output ))
579+
580+ // Parse JSON response
581+ var forkedStatus dbos.WorkflowStatus
582+ err = json .Unmarshal (output , & forkedStatus )
583+ require .NoError (t , err , "Fork from step JSON output should be valid" )
584+
585+ assert .NotEqual (t , workflowID , forkedStatus .ID , "Forked workflow should have different ID" )
586+ assert .Equal (t , "ENQUEUED" , string (forkedStatus .Status ), "Forked workflow should be enqueued" )
587+ assert .Equal (t , dbosInternalQueueName , forkedStatus .QueueName , "Should be on internal queue" )
588+ })
567589}
568590
569591// testGetWorkflowSteps tests retrieving workflow steps
@@ -607,24 +629,6 @@ func testGetWorkflowSteps(t *testing.T, cliPath string) {
607629 assert .NotEmpty (t , step .StepName , fmt .Sprintf ("Step name should not be empty for workflow %s" , workflowID ))
608630 }
609631 })
610-
611- t .Run ("GetStepsHumanReadable" , func (t * testing.T ) {
612- cmd := exec .Command (cliPath , "workflow" , "steps" , workflowID )
613- cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL ())
614-
615- output , err := cmd .CombinedOutput ()
616- require .NoError (t , err , "Get workflow steps human readable command failed: %s" , string (output ))
617-
618- outputStr := string (output )
619- // Should contain workflow ID reference
620- assert .Contains (t , outputStr , workflowID , "Output should reference the workflow ID" )
621-
622- // Should either show steps or indicate no steps found
623- assert .True (t ,
624- assert .Contains (t , outputStr , "Steps for workflow" ) ||
625- assert .Contains (t , outputStr , "No steps found" ),
626- "Output should either show steps or indicate none found" )
627- })
628632}
629633
630634// testErrorHandling tests various error conditions and edge cases
@@ -639,7 +643,7 @@ func testErrorHandling(t *testing.T, cliPath string) {
639643
640644 output , err := cmd .CombinedOutput ()
641645 assert .Error (t , err , "Should fail with invalid workflow ID" )
642- assert .Contains (t , string (output ), "failed to retrieve workflow " , "Should contain error message" )
646+ assert .Contains (t , string (output ), "workflow not found " , "Should contain error message" )
643647 })
644648
645649 t .Run ("MissingWorkflowID" , func (t * testing.T ) {
@@ -684,22 +688,6 @@ func testErrorHandling(t *testing.T, cliPath string) {
684688 assert .Contains (t , outputStr , "url" ),
685689 "Should contain database-related error" )
686690 })
687-
688- t .Run ("ForkWithInvalidStep" , func (t * testing.T ) {
689- workflowID := getFirstWorkflowID (t , cliPath )
690- if workflowID == "" {
691- t .Skip ("No workflows found for fork test" )
692- }
693-
694- // Test fork with invalid step number (0 should be converted to 1)
695- cmd := exec .Command (cliPath , "workflow" , "fork" , workflowID , "--step" , "0" )
696- cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL ())
697-
698- output , err := cmd .CombinedOutput ()
699- // This should not error as step 0 gets converted to 1
700- require .NoError (t , err , "Fork with step 0 should succeed: %s" , string (output ))
701- assert .Contains (t , string (output ), "Starting from step: 1" , "Step 0 should be converted to 1" )
702- })
703691}
704692
705693// Helper functions
@@ -729,21 +717,3 @@ func buildCLI(t *testing.T) string {
729717 require .NoError (t , err , "Failed to get absolute path" )
730718 return absPath
731719}
732-
733- func getFirstWorkflowID (t * testing.T , cliPath string ) string {
734- cmd := exec .Command (cliPath , "workflow" , "list" , "--limit" , "1" )
735- cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL ())
736-
737- output , err := cmd .CombinedOutput ()
738- require .NoError (t , err , "Failed to list workflows: %s" , string (output ))
739-
740- var workflows []dbos.WorkflowStatus
741- err = json .Unmarshal (output , & workflows )
742- require .NoError (t , err , "Failed to parse workflow JSON" )
743-
744- if len (workflows ) == 0 {
745- return ""
746- }
747-
748- return workflows [0 ].ID
749- }
0 commit comments