@@ -21,7 +21,9 @@ import (
21
21
"os"
22
22
"path/filepath"
23
23
"runtime"
24
+ "strings"
24
25
"testing"
26
+ "time"
25
27
26
28
"gotest.tools/v3/assert"
27
29
"gotest.tools/v3/icmd"
@@ -121,17 +123,19 @@ services:
121
123
fmt .Printf ("Docker Compose YAML content:\n %s\n " , dockerComposeYAML )
122
124
123
125
// Run compose up with env-file
124
- upCmd := base .ComposeCmd ("-f " , comp . YAMLFullPath () , "--env-file " , envFilePath , "up" , "-d" )
126
+ upCmd := base .ComposeCmd ("--env-file " , envFilePath , "-f " , comp . YAMLFullPath () , "up" , "-d" )
125
127
upCmd .AssertOK ()
128
+ time .Sleep (5 * time .Second )
126
129
defer base .ComposeCmd ("-f" , comp .YAMLFullPath (), "down" ).AssertOK ()
127
130
128
- // Print compose logs
129
- logsCmd := base .ComposeCmd ("-f" , comp .YAMLFullPath (), "logs" )
130
- fmt .Printf ("Compose logs:\n %s\n " , logsCmd .Run ().Combined ())
131
+ psCmd := base .ComposeCmd ("-f" , comp .YAMLFullPath (), "ps" )
132
+ fmt .Printf ("Compose ps output:\n %s\n " , psCmd .Run ().Combined ())
131
133
132
- // Get container ID
133
- containerID := base .ComposeCmd ("-f" , comp .YAMLFullPath (), "ps" , "-q" ).OutLines ()[0 ]
134
+ containerID := strings .TrimSpace (base .ComposeCmd ("-f" , comp .YAMLFullPath (), "ps" , "-q" ).Out ())
134
135
fmt .Printf ("Container ID: %s\n " , containerID )
136
+ if containerID == "" {
137
+ t .Fatalf ("Failed to get container ID" )
138
+ }
135
139
136
140
// Execute command in the container
137
141
execCmd := base .Cmd ("exec" , containerID , "cat" , "/tmp/test_output" )
0 commit comments