mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
eef6eda7d2
Part of #14603 integration-cli/docker_cli_links_test.go (coolljt0725) integration-cli/docker_cli_links_unix_test.go (coolljt0725) integration-cli/docker_cli_logs_test.go (coolljt0725) integration-cli/docker_cli_nat_test.go (coolljt0725) integration-cli/docker_cli_network_test.go (coolljt0725) integration-cli/docker_cli_stats_test.go (coolljt0725) integration-cli/docker_cli_tag_test.go (coolljt0725) integration-cli/docker_cli_top_test.go (coolljt0725) integration-cli/docker_cli_version_test.go (coolljt0725) integration-cli/docker_cli_wait_test.go (coolljt0725 Signed-off-by: Lei Jitang <leijitang@huawei.com>
47 lines
1,011 B
Go
47 lines
1,011 B
Go
// +build experimental
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/go-check/check"
|
|
)
|
|
|
|
func assertNwIsAvailable(c *check.C, name string) {
|
|
if !isNwPresent(c, name) {
|
|
c.Fatalf("Network %s not found in network ls o/p", name)
|
|
}
|
|
}
|
|
|
|
func assertNwNotAvailable(c *check.C, name string) {
|
|
if isNwPresent(c, name) {
|
|
c.Fatalf("Found network %s in network ls o/p", name)
|
|
}
|
|
}
|
|
|
|
func isNwPresent(c *check.C, name string) bool {
|
|
out, _ := dockerCmd(c, "network", "ls")
|
|
lines := strings.Split(out, "\n")
|
|
for i := 1; i < len(lines)-1; i++ {
|
|
if strings.Contains(lines[i], name) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (s *DockerSuite) TestDockerNetworkLsDefault(c *check.C) {
|
|
defaults := []string{"bridge", "host", "none"}
|
|
for _, nn := range defaults {
|
|
assertNwIsAvailable(c, nn)
|
|
}
|
|
}
|
|
|
|
func (s *DockerSuite) TestDockerNetworkCreateDelete(c *check.C) {
|
|
dockerCmd(c, "network", "create", "test")
|
|
assertNwIsAvailable(c, "test")
|
|
|
|
dockerCmd(c, "network", "rm", "test")
|
|
assertNwNotAvailable(c, "test")
|
|
}
|