Skip to content

Commit eed1666

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 eed1666

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
@@ -20,12 +20,17 @@ import (
2020
"fmt"
2121
"testing"
2222

23+
"github.com/containerd/nerdctl/mod/tigron/expect"
24+
"github.com/containerd/nerdctl/mod/tigron/test"
2325
"github.com/containerd/nerdctl/v2/pkg/testutil"
26+
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
2427
)
2528

2629
func TestComposePullWithService(t *testing.T) {
27-
base := testutil.NewBase(t)
28-
var dockerComposeYAML = fmt.Sprintf(`
30+
testCase := nerdtest.Setup()
31+
32+
testCase.Setup = func(data test.Data, helpers test.Helpers) {
33+
var composeYAML = fmt.Sprintf(`
2934
services:
3035
3136
wordpress:
@@ -53,10 +58,26 @@ volumes:
5358
db:
5459
`, testutil.WordpressImage, testutil.MariaDBImage)
5560

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

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

0 commit comments

Comments
 (0)