diff --git a/cli/command/volume/update.go b/cli/command/volume/update.go index c04c2ff8f507..42ce9ac586be 100644 --- a/cli/command/volume/update.go +++ b/cli/command/volume/update.go @@ -18,7 +18,7 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ Use: "update [OPTIONS] [VOLUME]", Short: "Update a volume (cluster volumes only)", - Args: cli.RequiresMaxArgs(1), + Args: cli.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { return runUpdate(cmd.Context(), dockerCli, args[0], availability, cmd.Flags()) }, diff --git a/cli/command/volume/update_test.go b/cli/command/volume/update_test.go new file mode 100644 index 000000000000..13051a0056fa --- /dev/null +++ b/cli/command/volume/update_test.go @@ -0,0 +1,22 @@ +package volume + +import ( + "io" + "testing" + + "github.com/docker/cli/internal/test" + "gotest.tools/v3/assert" +) + +func TestUpdateCmd(t *testing.T) { + cmd := newUpdateCommand( + test.NewFakeCli(&fakeClient{}), + ) + cmd.SetArgs([]string{}) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires exactly 1 argument") +}