Skip to content

Commit

Permalink
Merge pull request #9564 from docker/nicksieger/9562
Browse files Browse the repository at this point in the history
down: fix COMPOSE_REMOVE_ORPHANS env name and add test
  • Loading branch information
nicksieger authored Jun 16, 2022
2 parents de0f233 + 49fb4ca commit 71b89c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/compose/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
ValidArgsFunction: noCompletion(),
}
flags := downCmd.Flags()
removeOrphans := utils.StringToBool(os.Getenv("COMPOSE_REMOVE_ORPHANS "))
removeOrphans := utils.StringToBool(os.Getenv("COMPOSE_REMOVE_ORPHANS"))
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file.")
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
flags.BoolVarP(&opts.volumes, "volumes", "v", false, " Remove named volumes declared in the `volumes` section of the Compose file and anonymous volumes attached to containers.")
Expand Down
6 changes: 4 additions & 2 deletions pkg/e2e/compose_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ func TestLocalComposeRun(t *testing.T) {
})

t.Run("down", func(t *testing.T) {
c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/compose.yaml", "down")
c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/orphan.yaml", "down")
cmd := c.NewDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "down")
icmd.RunCmd(cmd, func(c *icmd.Cmd) {
c.Env = append(c.Env, "COMPOSE_REMOVE_ORPHANS=True")
})
res := c.RunDockerCmd(t, "ps", "--all")
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
})
Expand Down

0 comments on commit 71b89c2

Please sign in to comment.