Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -34,6 +34,7 @@ func (cli *DockerCli) CmdVolume(args ...string) error {
|
| 34 | 34 |
|
| 35 | 35 |
description += "\nRun 'docker volume COMMAND --help' for more information on a command." |
| 36 | 36 |
cmd := Cli.Subcmd("volume", []string{"[COMMAND]"}, description, true)
|
| 37 |
+ cmd.Require(flag.Exact, 0) |
|
| 37 | 38 |
cmd.ParseFlags(args, true) |
| 38 | 39 |
|
| 39 | 40 |
return cli.CmdVolumeLs(args...) |
| ... | ... |
@@ -88,3 +88,16 @@ func (s *DockerSuite) TestVolumeCliRm(c *check.C) {
|
| 88 | 88 |
check.Commentf("volume rm should fail with non-existant volume"),
|
| 89 | 89 |
) |
| 90 | 90 |
} |
| 91 |
+ |
|
| 92 |
+func (s *DockerSuite) TestVolumeCliNoArgs(c *check.C) {
|
|
| 93 |
+ out, _ := dockerCmd(c, "volume") |
|
| 94 |
+ // no args should produce the `volume ls` output |
|
| 95 |
+ c.Assert(strings.Contains(out, "DRIVER"), check.Equals, true) |
|
| 96 |
+ |
|
| 97 |
+ // invalid arg should error and show the command usage on stderr |
|
| 98 |
+ _, stderr, _, err := runCommandWithStdoutStderr(exec.Command(dockerBinary, "volume", "somearg")) |
|
| 99 |
+ c.Assert(err, check.NotNil) |
|
| 100 |
+ |
|
| 101 |
+ expected := "Usage: docker volume [OPTIONS] [COMMAND]" |
|
| 102 |
+ c.Assert(strings.Contains(stderr, expected), check.Equals, true) |
|
| 103 |
+} |