Skip to content

Commit

Permalink
test: add integration test for #1938
Browse files Browse the repository at this point in the history
  • Loading branch information
Retrospection committed Feb 9, 2023
1 parent 59b087b commit a5e3a89
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cmd/nerdctl/compose_down_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,44 @@ import (
"github.com/containerd/nerdctl/pkg/testutil"
)

func TestComposeDownRemoveUsedNetwork(t *testing.T) {
base := testutil.NewBase(t)

var (
dockerComposeYAMLOrphan = fmt.Sprintf(`
version: '3.1'
services:
test:
image: %s
command: "sleep infinity"
`, testutil.AlpineImage)

dockerComposeYAMLFull = fmt.Sprintf(`
%s
orphan:
image: %s
command: "sleep infinity"
`, dockerComposeYAMLOrphan, testutil.AlpineImage)
)

compOrphan := testutil.NewComposeDir(t, dockerComposeYAMLOrphan)
defer compOrphan.CleanUp()
compFull := testutil.NewComposeDir(t, dockerComposeYAMLFull)
defer compFull.CleanUp()

projectName := fmt.Sprintf("nerdctl-compose-test-%d", time.Now().Unix())
t.Logf("projectName=%q", projectName)

// orphanContainer := fmt.Sprintf("%s_orphan_1", projectName)

base.ComposeCmd("-p", projectName, "-f", compFull.YAMLFullPath(), "up", "-d").AssertOK()
// defer base.ComposeCmd("-p", projectName, "-f", compFull.YAMLFullPath(), "down", "-v").Run()

base.ComposeCmd("-p", projectName, "-f", compOrphan.YAMLFullPath(), "down", "-v").AssertOutContains("is in use")
// base.ComposeCmd("-p", projectName, "-f", compFull.YAMLFullPath(), "ps").AssertOutNotContains(orphanContainer)
}

func TestComposeDownRemoveOrphans(t *testing.T) {
base := testutil.NewBase(t)

Expand Down

0 comments on commit a5e3a89

Please sign in to comment.