Skip to content

Commit 9b48d86

Browse files
committed
update 1
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent ec9fa00 commit 9b48d86

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cmd/nerdctl/compose/compose_up_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import (
2121
"os"
2222
"path/filepath"
2323
"runtime"
24+
"strings"
2425
"testing"
26+
"time"
2527

2628
"gotest.tools/v3/assert"
2729
"gotest.tools/v3/icmd"
@@ -121,17 +123,19 @@ services:
121123
fmt.Printf("Docker Compose YAML content:\n%s\n", dockerComposeYAML)
122124

123125
// 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")
125127
upCmd.AssertOK()
128+
time.Sleep(5 * time.Second)
126129
defer base.ComposeCmd("-f", comp.YAMLFullPath(), "down").AssertOK()
127130

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())
131133

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())
134135
fmt.Printf("Container ID: %s\n", containerID)
136+
if containerID == "" {
137+
t.Fatalf("Failed to get container ID")
138+
}
135139

136140
// Execute command in the container
137141
execCmd := base.Cmd("exec", containerID, "cat", "/tmp/test_output")

0 commit comments

Comments
 (0)