Skip to content

Commit

Permalink
Merge pull request #5510 from austinvazquez/cherry-pick-daea277ee8397…
Browse files Browse the repository at this point in the history
…42be94e1f41d5c477f114a81273-to-26.1

[26.1 backport] volume/update: require 1 argument/fix panic
  • Loading branch information
thaJeztah authored Oct 8, 2024
2 parents 3c827ab + 23a8d38 commit fb622db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/command/volume/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
},
Expand Down
22 changes: 22 additions & 0 deletions cli/command/volume/update_test.go
Original file line number Diff line number Diff line change
@@ -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")
}

0 comments on commit fb622db

Please sign in to comment.