docker_deprecated_api_v124_unix_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. //go:build !windows
  2. package main
  3. import (
  4. "strings"
  5. "testing"
  6. "github.com/docker/docker/integration-cli/cli"
  7. "github.com/docker/docker/testutil"
  8. "github.com/docker/docker/testutil/request"
  9. "gotest.tools/v3/assert"
  10. )
  11. // #19100 This is a deprecated feature test, it should be removed in Docker 1.12
  12. func (s *DockerNetworkSuite) TestDeprecatedDockerNetworkStartAPIWithHostconfig(c *testing.T) {
  13. const netName = "test"
  14. const conName = "foo"
  15. cli.DockerCmd(c, "network", "create", netName)
  16. cli.DockerCmd(c, "create", "--name", conName, "busybox", "top")
  17. config := map[string]interface{}{
  18. "HostConfig": map[string]interface{}{
  19. "NetworkMode": netName,
  20. },
  21. }
  22. _, _, err := request.Post(testutil.GetContext(c), formatV123StartAPIURL("/containers/"+conName+"/start"), request.JSONBody(config))
  23. assert.NilError(c, err)
  24. cli.WaitRun(c, conName)
  25. networks := inspectField(c, conName, "NetworkSettings.Networks")
  26. assert.Assert(c, strings.Contains(networks, netName), "Should contain '%s' network", netName)
  27. assert.Assert(c, !strings.Contains(networks, "bridge"), "Should not contain 'bridge' network")
  28. }