Skip to content

Commit 2fbdca1

Browse files
authored
Merge pull request #4796 from juannio/issues-4613-migrate-compose-pull-tests
test: refactor compose_pull_linux_test.go to use nerdtest/tigron
2 parents f5a981e + 667c894 commit 2fbdca1

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

cmd/nerdctl/compose/compose_pull_linux_test.go

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@ package compose
1818

1919
import (
2020
"fmt"
21+
"path/filepath"
2122
"testing"
2223

24+
"github.com/containerd/nerdctl/mod/tigron/expect"
25+
"github.com/containerd/nerdctl/mod/tigron/test"
26+
2327
"github.com/containerd/nerdctl/v2/pkg/testutil"
28+
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
2429
)
2530

2631
func TestComposePullWithService(t *testing.T) {
27-
base := testutil.NewBase(t)
28-
var dockerComposeYAML = fmt.Sprintf(`
32+
testCase := nerdtest.Setup()
33+
34+
testCase.Setup = func(data test.Data, helpers test.Helpers) {
35+
var composeYAML = fmt.Sprintf(`
2936
services:
3037
3138
wordpress:
@@ -53,10 +60,24 @@ volumes:
5360
db:
5461
`, testutil.WordpressImage, testutil.MariaDBImage)
5562

56-
comp := testutil.NewComposeDir(t, dockerComposeYAML)
57-
defer comp.CleanUp()
58-
projectName := comp.ProjectName()
59-
t.Logf("projectName=%q", projectName)
63+
composePath := data.Temp().Save(composeYAML, "compose.yaml")
64+
65+
projectName := filepath.Base(filepath.Dir(composePath))
66+
t.Logf("projectName=%q", projectName)
67+
68+
data.Labels().Set("composeYAML", composePath)
69+
}
70+
71+
testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
72+
return helpers.Command("compose", "-f", data.Labels().Get("composeYAML"), "pull", "db")
73+
}
74+
75+
testCase.Expected = func(data test.Data, helpers test.Helpers) *test.Expected {
76+
return &test.Expected{
77+
ExitCode: 0,
78+
Output: expect.DoesNotContain("wordpress"),
79+
}
80+
}
6081

61-
base.ComposeCmd("-f", comp.YAMLFullPath(), "pull", "db").AssertOutNotContains("wordpress")
82+
testCase.Run(t)
6283
}

0 commit comments

Comments
 (0)