|
@@ -6,15 +6,16 @@ import (
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types/versions"
|
|
"github.com/docker/docker/api/types/versions"
|
|
|
|
+ "github.com/docker/docker/integration/internal/network"
|
|
"github.com/docker/docker/internal/test/request"
|
|
"github.com/docker/docker/internal/test/request"
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
|
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
|
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
|
"github.com/gotestyourself/gotestyourself/skip"
|
|
"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 {
|
|
for _, n := range nws {
|
|
- if n.ID == nw.ID {
|
|
|
|
|
|
+ if n.ID == networkID {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -26,16 +27,13 @@ func containsNetwork(nws []types.NetworkResource, nw types.NetworkCreateResponse
|
|
// first network's ID as name.
|
|
// first network's ID as name.
|
|
//
|
|
//
|
|
// After successful creation, properties of all three networks is returned
|
|
// 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)
|
|
client := request.NewAPIClient(t)
|
|
ctx := context.Background()
|
|
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{})
|
|
nws, err := client.NetworkList(ctx, types.NetworkListOptions{})
|
|
assert.NilError(t, err)
|
|
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.
|
|
// 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.
|
|
// 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)
|
|
assert.NilError(t, err)
|
|
|
|
|
|
// Delete the network using networkID. This should remove the original
|
|
// Delete the network using networkID. This should remove the original
|
|
// network, not the network with the name equal to the networkID
|
|
// 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)
|
|
assert.NilError(t, err)
|
|
|
|
|
|
// networks "testNet" and "idPrefixNet" should be removed, but "fullIDNet" should still exist
|
|
// networks "testNet" and "idPrefixNet" should be removed, but "fullIDNet" should still exist
|