@@ -18,14 +18,21 @@ package compose
1818
1919import (
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
2631func 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 (`
2936services:
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