Skip to content

Commit

Permalink
Fix docker volume invalid so it displays usage
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Aug 27, 2015
1 parent 44ea7e9 commit 38da431
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/client/volume.go
Expand Up @@ -34,6 +34,7 @@ func (cli *DockerCli) CmdVolume(args ...string) error {

description += "\nRun 'docker volume COMMAND --help' for more information on a command."
cmd := Cli.Subcmd("volume", []string{"[COMMAND]"}, description, true)
cmd.Require(flag.Exact, 0)
cmd.ParseFlags(args, true)

return cli.CmdVolumeLs(args...)
Expand Down
13 changes: 13 additions & 0 deletions integration-cli/docker_cli_volume_test.go
Expand Up @@ -88,3 +88,16 @@ func (s *DockerSuite) TestVolumeCliRm(c *check.C) {
check.Commentf("volume rm should fail with non-existant volume"),
)
}

func (s *DockerSuite) TestVolumeCliNoArgs(c *check.C) {
out, _ := dockerCmd(c, "volume")
// no args should produce the `volume ls` output
c.Assert(strings.Contains(out, "DRIVER"), check.Equals, true)

// invalid arg should error and show the command usage on stderr
_, stderr, _, err := runCommandWithStdoutStderr(exec.Command(dockerBinary, "volume", "somearg"))
c.Assert(err, check.NotNil)

expected := "Usage: docker volume [OPTIONS] [COMMAND]"
c.Assert(strings.Contains(stderr, expected), check.Equals, true)
}

0 comments on commit 38da431

Please sign in to comment.