Files
docker-cli/cli/command/node/remove_test.go
Sebastiaan van Stijn 4f7c07cfc2 update local code for updated modules
Some tests had to be skipped as there's some issues to address, and
some of the result-types cannot be mocked / stubbed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-24 10:28:54 +02:00

47 lines
1.0 KiB
Go

package node
import (
"errors"
"io"
"testing"
"github.com/docker/cli/internal/test"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
)
func TestNodeRemoveErrors(t *testing.T) {
testCases := []struct {
args []string
nodeRemoveFunc func() (client.NodeRemoveResult, error)
expectedError string
}{
{
expectedError: "requires at least 1 argument",
},
{
args: []string{"nodeID"},
nodeRemoveFunc: func() (client.NodeRemoveResult, error) {
return client.NodeRemoveResult{}, errors.New("error removing the node")
},
expectedError: "error removing the node",
},
}
for _, tc := range testCases {
cmd := newRemoveCommand(
test.NewFakeCli(&fakeClient{
nodeRemoveFunc: tc.nodeRemoveFunc,
}))
cmd.SetArgs(tc.args)
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
func TestNodeRemoveMultiple(t *testing.T) {
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}))
cmd.SetArgs([]string{"nodeID1", "nodeID2"})
assert.NilError(t, cmd.Execute())
}