mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
migrate TestAPINetworkInspectWithScope to integration test
Signed-off-by: Aditya Mishra <mishraaditya675@gmail.com>
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/cloudflare/cfssl/csr"
|
||||
"github.com/cloudflare/cfssl/helpers"
|
||||
"github.com/cloudflare/cfssl/initca"
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
@@ -1019,22 +1018,3 @@ func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *testing.T) {
|
||||
currentTrustRoot = clusterTLSInfo.TrustRoot
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *testing.T) {
|
||||
ctx := testutil.GetContext(c)
|
||||
d := s.AddDaemon(ctx, c, true, true)
|
||||
|
||||
name := "test-scoped-network"
|
||||
apiclient := d.NewClientT(c)
|
||||
|
||||
create, err := apiclient.NetworkCreate(ctx, name, client.NetworkCreateOptions{Driver: "overlay"})
|
||||
assert.NilError(c, err)
|
||||
|
||||
inspect, err := apiclient.NetworkInspect(ctx, name, client.NetworkInspectOptions{})
|
||||
assert.NilError(c, err)
|
||||
assert.Check(c, is.Equal("swarm", inspect.Network.Scope))
|
||||
assert.Check(c, is.Equal(create.ID, inspect.Network.ID))
|
||||
|
||||
_, err = apiclient.NetworkInspect(ctx, name, client.NetworkInspectOptions{Scope: "local"})
|
||||
assert.Check(c, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/integration/internal/swarm"
|
||||
"github.com/moby/moby/v2/internal/testutil"
|
||||
"github.com/moby/moby/v2/internal/testutil/request"
|
||||
"gotest.tools/v3/assert"
|
||||
@@ -144,3 +146,24 @@ func TestAPINetworkFilter(t *testing.T) {
|
||||
}
|
||||
assert.Assert(t, found, fmt.Sprintf("%s is not found", networkName))
|
||||
}
|
||||
|
||||
func TestNetworkInspectWithScope(t *testing.T) {
|
||||
ctx := setupTest(t)
|
||||
|
||||
d := swarm.NewSwarm(ctx, t, testEnv)
|
||||
defer d.Stop(t)
|
||||
|
||||
cli := d.NewClientT(t) // IMPORTANT: talk to swarm daemon
|
||||
|
||||
name := "test-scoped-network"
|
||||
create, err := cli.NetworkCreate(ctx, name, client.NetworkCreateOptions{Driver: "overlay"})
|
||||
assert.NilError(t, err)
|
||||
|
||||
inspect, err := cli.NetworkInspect(ctx, name, client.NetworkInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("swarm", inspect.Network.Scope))
|
||||
assert.Check(t, is.Equal(create.ID, inspect.Network.ID))
|
||||
|
||||
_, err = cli.NetworkInspect(ctx, name, client.NetworkInspectOptions{Scope: "local"})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user