cli/command/network: use stdlib errors, remove errdefs uses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -8,11 +8,18 @@ import (
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
||||
type forBiddenErr struct{ error }
|
||||
|
||||
func (forBiddenErr) Forbidden() {}
|
||||
|
||||
type notFoundErr struct{ error }
|
||||
|
||||
func (notFoundErr) NotFound() {}
|
||||
|
||||
func TestNetworkRemoveForce(t *testing.T) {
|
||||
tests := []struct {
|
||||
doc string
|
||||
@ -68,9 +75,9 @@ func TestNetworkRemoveForce(t *testing.T) {
|
||||
networkRemoveFunc: func(ctx context.Context, networkID string) error {
|
||||
switch networkID {
|
||||
case "no-such-network":
|
||||
return errdefs.NotFound(errors.New("no such network: no-such-network"))
|
||||
return notFoundErr{errors.New("no such network: no-such-network")}
|
||||
case "in-use-network":
|
||||
return errdefs.Forbidden(errors.New("network is in use"))
|
||||
return forBiddenErr{errors.New("network is in use")}
|
||||
case "existing-network":
|
||||
return nil
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user