Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions cmd/nerdctl/compose/compose_pull_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ package compose

import (
"fmt"
"path/filepath"
"testing"

"github.com/containerd/nerdctl/mod/tigron/expect"
"github.com/containerd/nerdctl/mod/tigron/test"

"github.com/containerd/nerdctl/v2/pkg/testutil"
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
)

func TestComposePullWithService(t *testing.T) {
base := testutil.NewBase(t)
var dockerComposeYAML = fmt.Sprintf(`
testCase := nerdtest.Setup()

testCase.Setup = func(data test.Data, helpers test.Helpers) {
var composeYAML = fmt.Sprintf(`
services:

wordpress:
Expand Down Expand Up @@ -53,10 +60,24 @@ volumes:
db:
`, testutil.WordpressImage, testutil.MariaDBImage)

comp := testutil.NewComposeDir(t, dockerComposeYAML)
defer comp.CleanUp()
projectName := comp.ProjectName()
t.Logf("projectName=%q", projectName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please display projectName in the log.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed, thanks!

composePath := data.Temp().Save(composeYAML, "compose.yaml")

projectName := filepath.Base(filepath.Dir(composePath))
t.Logf("projectName=%q", projectName)

data.Labels().Set("composeYAML", composePath)
}

testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
return helpers.Command("compose", "-f", data.Labels().Get("composeYAML"), "pull", "db")
}

testCase.Expected = func(data test.Data, helpers test.Helpers) *test.Expected {
return &test.Expected{
ExitCode: 0,
Output: expect.DoesNotContain("wordpress"),
}
}

base.ComposeCmd("-f", comp.YAMLFullPath(), "pull", "db").AssertOutNotContains("wordpress")
testCase.Run(t)
}
Loading