cli/command/network: use stdlib errors, remove errdefs uses

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-05-16 19:48:17 +02:00
parent 3382ee3e99
commit 981e75e0f4
3 changed files with 25 additions and 15 deletions

View File

@ -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: