Skip to content

Commit 61fcc6c

Browse files
committed
test: refactor compose_pull_linux_test.go to use nerdtest/tigron
Signed-off-by: juannio <juaniorosas.99@gmail.com>
1 parent d5bc0f0 commit 61fcc6c

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

cmd/nerdctl/compose/compose_pull_linux_test.go

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ import (
2020
"fmt"
2121
"testing"
2222

23+
"github.com/containerd/nerdctl/mod/tigron/expect"
24+
"github.com/containerd/nerdctl/mod/tigron/test"
25+
2326
"github.com/containerd/nerdctl/v2/pkg/testutil"
27+
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
2428
)
2529

2630
func TestComposePullWithService(t *testing.T) {
27-
base := testutil.NewBase(t)
28-
var dockerComposeYAML = fmt.Sprintf(`
31+
testCase := nerdtest.Setup()
32+
33+
testCase.Setup = func(data test.Data, helpers test.Helpers) {
34+
var composeYAML = fmt.Sprintf(`
2935
services:
3036
3137
wordpress:
@@ -53,10 +59,26 @@ volumes:
5359
db:
5460
`, testutil.WordpressImage, testutil.MariaDBImage)
5561

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

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

0 commit comments

Comments
 (0)