From 991d5121592eeb1e4442516f957ed484d8b687c7 Mon Sep 17 00:00:00 2001 From: Arash Deshmeh Date: Sat, 9 Jun 2018 06:39:22 -0400 Subject: [PATCH] refactor delete network integration tests to use network package Signed-off-by: Arash Deshmeh --- integration/network/delete_test.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/integration/network/delete_test.go b/integration/network/delete_test.go index f937da5274..83d00bbdf1 100644 --- a/integration/network/delete_test.go +++ b/integration/network/delete_test.go @@ -6,15 +6,16 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" + "github.com/docker/docker/integration/internal/network" "github.com/docker/docker/internal/test/request" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" "github.com/gotestyourself/gotestyourself/skip" ) -func containsNetwork(nws []types.NetworkResource, nw types.NetworkCreateResponse) bool { +func containsNetwork(nws []types.NetworkResource, networkID string) bool { for _, n := range nws { - if n.ID == nw.ID { + if n.ID == networkID { return true } } @@ -26,16 +27,13 @@ func containsNetwork(nws []types.NetworkResource, nw types.NetworkCreateResponse // first network's ID as name. // // After successful creation, properties of all three networks is returned -func createAmbiguousNetworks(t *testing.T) (types.NetworkCreateResponse, types.NetworkCreateResponse, types.NetworkCreateResponse) { +func createAmbiguousNetworks(t *testing.T) (string, string, string) { client := request.NewAPIClient(t) ctx := context.Background() - testNet, err := client.NetworkCreate(ctx, "testNet", types.NetworkCreate{}) - assert.NilError(t, err) - idPrefixNet, err := client.NetworkCreate(ctx, testNet.ID[:12], types.NetworkCreate{}) - assert.NilError(t, err) - fullIDNet, err := client.NetworkCreate(ctx, testNet.ID, types.NetworkCreate{}) - assert.NilError(t, err) + testNet := network.CreateNoError(t, ctx, client, "testNet") + idPrefixNet := network.CreateNoError(t, ctx, client, testNet[:12]) + fullIDNet := network.CreateNoError(t, ctx, client, testNet) nws, err := client.NetworkList(ctx, types.NetworkListOptions{}) assert.NilError(t, err) @@ -58,12 +56,12 @@ func TestDockerNetworkDeletePreferID(t *testing.T) { // Delete the network using a prefix of the first network's ID as name. // This should the network name with the id-prefix, not the original network. - err := client.NetworkRemove(ctx, testNet.ID[:12]) + err := client.NetworkRemove(ctx, testNet[:12]) assert.NilError(t, err) // Delete the network using networkID. This should remove the original // network, not the network with the name equal to the networkID - err = client.NetworkRemove(ctx, testNet.ID) + err = client.NetworkRemove(ctx, testNet) assert.NilError(t, err) // networks "testNet" and "idPrefixNet" should be removed, but "fullIDNet" should still exist