gopkg.in/docker/docker.v20@v20.10.27/integration-cli/docker_deprecated_api_v124_unix_test.go (about)

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