Bläddra i källkod

refactored integration/service/network integration tests to use network package

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
Arash Deshmeh 7 år sedan
förälder
incheckning
8b07ec58ea
2 ändrade filer med 13 tillägg och 6 borttagningar
  1. 7 0
      integration/internal/network/ops.go
  2. 6 6
      integration/service/network_test.go

+ 7 - 0
integration/internal/network/ops.go

@@ -33,6 +33,13 @@ func WithInternal() func(*types.NetworkCreate) {
 	}
 }
 
+// WithAttachable sets Attachable flag on the create network request
+func WithAttachable() func(*types.NetworkCreate) {
+	return func(n *types.NetworkCreate) {
+		n.Attachable = true
+	}
+}
+
 // WithMacvlan sets the network as macvlan with the specified parent
 func WithMacvlan(parent string) func(*types.NetworkCreate) {
 	return func(n *types.NetworkCreate) {

+ 6 - 6
integration/service/network_test.go

@@ -7,6 +7,7 @@ import (
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/network"
 	"github.com/docker/docker/integration/internal/container"
+	net "github.com/docker/docker/integration/internal/network"
 	"github.com/docker/docker/integration/internal/swarm"
 	"gotest.tools/assert"
 	is "gotest.tools/assert/cmp"
@@ -21,11 +22,10 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
 	ctx := context.Background()
 
 	name := t.Name() + "test-alias"
-	_, err := client.NetworkCreate(ctx, name, types.NetworkCreate{
-		Driver:     "overlay",
-		Attachable: true,
-	})
-	assert.NilError(t, err)
+	net.CreateNoError(t, ctx, client, name,
+		net.WithDriver("overlay"),
+		net.WithAttachable(),
+	)
 
 	cID1 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
 		c.NetworkingConfig = &network.NetworkingConfig{
@@ -35,7 +35,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
 		}
 	})
 
-	err = client.NetworkConnect(ctx, name, cID1, &network.EndpointSettings{
+	err := client.NetworkConnect(ctx, name, cID1, &network.EndpointSettings{
 		Aliases: []string{
 			"aaa",
 		},