From 570c5f9e764339effe6be9d57ea0aa3e81147695 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 4 Jun 2020 11:58:09 +0200 Subject: [PATCH] testing: remove use of docker/docker/errdefs in tests Signed-off-by: Sebastiaan van Stijn --- libnetwork/libnetwork_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libnetwork/libnetwork_test.go b/libnetwork/libnetwork_test.go index ace38e89a2..9bf877169e 100644 --- a/libnetwork/libnetwork_test.go +++ b/libnetwork/libnetwork_test.go @@ -10,7 +10,6 @@ import ( "sync" "testing" - "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/plugins" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork" @@ -90,6 +89,11 @@ func getPortMapping() []types.PortBinding { } } +func isNotFound(err error) bool { + _, ok := (err).(types.NotFoundError) + return ok +} + func TestNull(t *testing.T) { cnt, err := controller.NewSandbox("null_container", libnetwork.OptionHostname("test"), @@ -210,7 +214,7 @@ func TestUnknownDriver(t *testing.T) { t.Fatal("Expected to fail. But instead succeeded") } - if !errdefs.IsNotFound(err) { + if !isNotFound(err) { t.Fatalf("Did not fail with expected error. Actual error: %v", err) } } @@ -222,7 +226,7 @@ func TestNilRemoteDriver(t *testing.T) { t.Fatal("Expected to fail. But instead succeeded") } - if !errdefs.IsNotFound(err) { + if !isNotFound(err) { t.Fatalf("Did not fail with expected error. Actual error: %v", err) } } @@ -1405,7 +1409,7 @@ func TestValidRemoteDriver(t *testing.T) { libnetwork.NetworkOptionGeneric(getEmptyGenericOption())) if err != nil { // Only fail if we could not find the plugin driver - if errdefs.IsNotFound(err) { + if isNotFound(err) { t.Fatal(err) } return