11package main
22
33import (
4+ "bufio"
45 "context"
56 "database/sql"
67 _ "embed"
@@ -149,18 +150,29 @@ func TestCLIWorkflow(t *testing.T) {
149150
150151 // Start a test application using dbos start
151152 startArgs := append ([]string {"start" }, config .args ... )
152- if config .dbRole != "postgres" {
153- startArgs = append (startArgs , "--app-role" , config .dbRole )
154- }
155153 cmd := exec .CommandContext (context .Background (), cliPath , startArgs ... )
156154 envVars := append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (config .dbRole ))
157155 // Pass the schema to the test app if using custom schema
158156 if config .schemaName != "dbos" {
159157 envVars = append (envVars , "DBOS_SCHEMA=" + config .schemaName )
160158 }
161159 cmd .Env = envVars
162- err = cmd .Start ()
163- require .NoError (t , err , "Failed to start application" )
160+ stdout , _ := cmd .StdoutPipe ()
161+ stderr , _ := cmd .StderrPipe ()
162+ require .NoError (t , cmd .Start (), "Failed to start application" )
163+ go func () {
164+ scanner := bufio .NewScanner (stdout )
165+ for scanner .Scan () {
166+ t .Logf ("[app stdout] %s" , scanner .Text ())
167+ }
168+ }()
169+ go func () {
170+ scanner := bufio .NewScanner (stderr )
171+ for scanner .Scan () {
172+ t .Logf ("[app stderr] %s" , scanner .Text ())
173+ }
174+ }()
175+
164176 // Wait for server to be ready
165177 require .Eventually (t , func () bool {
166178 resp , err := http .Get ("http://localhost:" + testServerPort )
@@ -273,6 +285,7 @@ func testMigrateCommand(t *testing.T, cliPath string, baseArgs []string, dbRole
273285 output , err := cmd .CombinedOutput ()
274286 require .NoError (t , err , "Migrate command failed: %s" , string (output ))
275287 assert .Contains (t , string (output ), "DBOS migrations completed successfully" , "Output should confirm migration" )
288+ fmt .Println (string (output ))
276289}
277290
278291// testWorkflowCommands comprehensively tests all workflow CLI commands
@@ -447,9 +460,6 @@ func testListWorkflows(t *testing.T, cliPath string, baseArgs []string, dbRole s
447460 for _ , tc := range testCases {
448461 t .Run (tc .name , func (t * testing.T ) {
449462 args := append (tc .args , baseArgs ... )
450- if dbRole != "postgres" {
451- args = append (args , "--app-role" , dbRole )
452- }
453463 cmd := exec .Command (cliPath , args ... )
454464 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
455465
@@ -514,9 +524,6 @@ func testGetWorkflow(t *testing.T, cliPath string, baseArgs []string, dbRole str
514524
515525 t .Run ("GetWorkflowJSON" , func (t * testing.T ) {
516526 args := append ([]string {"workflow" , "get" , workflowID }, baseArgs ... )
517- if dbRole != "postgres" {
518- args = append (args , "--app-role" , dbRole )
519- }
520527 cmd := exec .Command (cliPath , args ... )
521528 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
522529
@@ -533,9 +540,6 @@ func testGetWorkflow(t *testing.T, cliPath string, baseArgs []string, dbRole str
533540
534541 // Redo the test with the db url in flags
535542 args2 := append ([]string {"workflow" , "get" , workflowID , "--db-url" , getDatabaseURL (dbRole )}, baseArgs ... )
536- if dbRole != "postgres" {
537- args2 = append (args2 , "--app-role" , dbRole )
538- }
539543 cmd2 := exec .Command (cliPath , args2 ... )
540544
541545 output2 , err2 := cmd2 .CombinedOutput ()
@@ -570,9 +574,6 @@ func testGetWorkflow(t *testing.T, cliPath string, baseArgs []string, dbRole str
570574
571575 // Test with environment variable D
572576 args3 := append ([]string {"workflow" , "get" , workflowID }, baseArgs ... )
573- if dbRole != "postgres" {
574- args3 = append (args3 , "--app-role" , dbRole )
575- }
576577 cmd3 := exec .Command (cliPath , args3 ... )
577578 cmd3 .Env = append (os .Environ (), "D=" + getDatabaseURL (dbRole ))
578579
@@ -611,9 +612,6 @@ func testCancelResumeWorkflow(t *testing.T, cliPath string, baseArgs []string, d
611612
612613 t .Run ("CancelWorkflow" , func (t * testing.T ) {
613614 args := append ([]string {"workflow" , "cancel" , workflowID }, baseArgs ... )
614- if dbRole != "postgres" {
615- args = append (args , "--app-role" , dbRole )
616- }
617615 cmd := exec .Command (cliPath , args ... )
618616 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
619617
@@ -624,9 +622,6 @@ func testCancelResumeWorkflow(t *testing.T, cliPath string, baseArgs []string, d
624622
625623 // Verify workflow is actually cancelled
626624 getArgs := append ([]string {"workflow" , "get" , workflowID }, baseArgs ... )
627- if dbRole != "postgres" {
628- getArgs = append (getArgs , "--app-role" , dbRole )
629- }
630625 getCmd := exec .Command (cliPath , getArgs ... )
631626 getCmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
632627
@@ -641,9 +636,6 @@ func testCancelResumeWorkflow(t *testing.T, cliPath string, baseArgs []string, d
641636
642637 t .Run ("ResumeWorkflow" , func (t * testing.T ) {
643638 args := append ([]string {"workflow" , "resume" , workflowID }, baseArgs ... )
644- if dbRole != "postgres" {
645- args = append (args , "--app-role" , dbRole )
646- }
647639 cmd := exec .Command (cliPath , args ... )
648640 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
649641
@@ -685,9 +677,6 @@ func testForkWorkflow(t *testing.T, cliPath string, baseArgs []string, dbRole st
685677 newID := uuid .NewString ()
686678 targetVersion := "1.0.0"
687679 args := append ([]string {"workflow" , "fork" , workflowID , "--forked-workflow-id" , newID , "--application-version" , targetVersion }, baseArgs ... )
688- if dbRole != "postgres" {
689- args = append (args , "--app-role" , dbRole )
690- }
691680 cmd := exec .Command (cliPath , args ... )
692681 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
693682
@@ -708,9 +697,6 @@ func testForkWorkflow(t *testing.T, cliPath string, baseArgs []string, dbRole st
708697
709698 t .Run ("ForkWorkflowFromStep" , func (t * testing.T ) {
710699 args := append ([]string {"workflow" , "fork" , workflowID , "--step" , "2" }, baseArgs ... )
711- if dbRole != "postgres" {
712- args = append (args , "--app-role" , dbRole )
713- }
714700 cmd := exec .Command (cliPath , args ... )
715701 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
716702
@@ -730,9 +716,6 @@ func testForkWorkflow(t *testing.T, cliPath string, baseArgs []string, dbRole st
730716 t .Run ("ForkWorkflowFromNegativeStep" , func (t * testing.T ) {
731717 // Test fork with invalid step number (0 should be converted to 1)
732718 args := append ([]string {"workflow" , "fork" , workflowID , "--step" , "-1" }, baseArgs ... )
733- if dbRole != "postgres" {
734- args = append (args , "--app-role" , dbRole )
735- }
736719 cmd := exec .Command (cliPath , args ... )
737720 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
738721
@@ -772,9 +755,6 @@ func testGetWorkflowSteps(t *testing.T, cliPath string, baseArgs []string, dbRol
772755
773756 t .Run ("GetStepsJSON" , func (t * testing.T ) {
774757 args := append ([]string {"workflow" , "steps" , workflowID }, baseArgs ... )
775- if dbRole != "postgres" {
776- args = append (args , "--app-role" , dbRole )
777- }
778758 cmd := exec .Command (cliPath , args ... )
779759 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
780760
@@ -804,9 +784,6 @@ func testErrorHandling(t *testing.T, cliPath string, baseArgs []string, dbRole s
804784
805785 // Test get with invalid ID
806786 args := append ([]string {"workflow" , "get" , invalidID }, baseArgs ... )
807- if dbRole != "postgres" {
808- args = append (args , "--app-role" , dbRole )
809- }
810787 cmd := exec .Command (cliPath , args ... )
811788 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
812789
@@ -818,9 +795,6 @@ func testErrorHandling(t *testing.T, cliPath string, baseArgs []string, dbRole s
818795 t .Run ("MissingWorkflowID" , func (t * testing.T ) {
819796 // Test get without workflow ID
820797 args := append ([]string {"workflow" , "get" }, baseArgs ... )
821- if dbRole != "postgres" {
822- args = append (args , "--app-role" , dbRole )
823- }
824798 cmd := exec .Command (cliPath , args ... )
825799 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
826800
@@ -831,9 +805,6 @@ func testErrorHandling(t *testing.T, cliPath string, baseArgs []string, dbRole s
831805
832806 t .Run ("InvalidStatusFilter" , func (t * testing.T ) {
833807 args := append ([]string {"workflow" , "list" , "--status" , "INVALID_STATUS" }, baseArgs ... )
834- if dbRole != "postgres" {
835- args = append (args , "--app-role" , dbRole )
836- }
837808 cmd := exec .Command (cliPath , args ... )
838809 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
839810
@@ -844,9 +815,6 @@ func testErrorHandling(t *testing.T, cliPath string, baseArgs []string, dbRole s
844815
845816 t .Run ("InvalidTimeFormat" , func (t * testing.T ) {
846817 args := append ([]string {"workflow" , "list" , "--start-time" , "invalid-time-format" }, baseArgs ... )
847- if dbRole != "postgres" {
848- args = append (args , "--app-role" , dbRole )
849- }
850818 cmd := exec .Command (cliPath , args ... )
851819 cmd .Env = append (os .Environ (), "DBOS_SYSTEM_DATABASE_URL=" + getDatabaseURL (dbRole ))
852820
@@ -858,9 +826,6 @@ func testErrorHandling(t *testing.T, cliPath string, baseArgs []string, dbRole s
858826 t .Run ("MissingDatabaseURL" , func (t * testing.T ) {
859827 // Test without system DB url in the flags or env var
860828 args := append ([]string {"workflow" , "list" }, baseArgs ... )
861- if dbRole != "postgres" {
862- args = append (args , "--app-role" , dbRole )
863- }
864829 cmd := exec .Command (cliPath , args ... )
865830
866831 output , err := cmd .CombinedOutput ()
0 commit comments