Files
docker-cli/cli/command/volume/remove_test.go
Sebastiaan van Stijn 4fe6b837b7 bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 2c0e93063b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:43:18 +02:00

45 lines
1.0 KiB
Go

package volume
import (
"io/ioutil"
"testing"
"github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
)
func TestVolumeRemoveErrors(t *testing.T) {
testCases := []struct {
args []string
volumeRemoveFunc func(volumeID string, force bool) error
expectedError string
}{
{
expectedError: "requires at least 1 argument",
},
{
args: []string{"nodeID"},
volumeRemoveFunc: func(volumeID string, force bool) error {
return errors.Errorf("error removing the volume")
},
expectedError: "error removing the volume",
},
}
for _, tc := range testCases {
cmd := newRemoveCommand(
test.NewFakeCli(&fakeClient{
volumeRemoveFunc: tc.volumeRemoveFunc,
}))
cmd.SetArgs(tc.args)
cmd.SetOutput(ioutil.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
func TestNodeRemoveMultiple(t *testing.T) {
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}))
cmd.SetArgs([]string{"volume1", "volume2"})
assert.NilError(t, cmd.Execute())
}