mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integration-cli: fix tests that are silently succeeding when they should not compile
Tests fixed in this patch used to compile and pass successfully,
despite checking if non-nullable types are not nil.
These would have become compile errors once go-check is removed.
About TestContainerAPIPsOmitFields:
Basically what happened is that this test got refactored to start using the API types
and API client library instead of custom types and stdlib's http functions.
This test used to test an API regression which could possibly be a unit test.
However because PublicPort and IP are not nullable types, this test became useless.
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit e07a3f2917
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
99799a9ab5
commit
e71e7d8246
3 changed files with 1 additions and 46 deletions
|
@ -13,7 +13,6 @@ import (
|
|||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -98,45 +97,6 @@ func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) {
|
|||
}
|
||||
}
|
||||
|
||||
type containerPs struct {
|
||||
Names []string
|
||||
Ports []types.Port
|
||||
}
|
||||
|
||||
// regression test for non-empty fields from #13901
|
||||
func (s *DockerSuite) TestContainerAPIPsOmitFields(c *check.C) {
|
||||
// Problematic for Windows porting due to networking not yet being passed back
|
||||
testRequires(c, DaemonIsLinux)
|
||||
name := "pstest"
|
||||
port := 80
|
||||
runSleepingContainer(c, "--name", name, "--expose", strconv.Itoa(port))
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
assert.NilError(c, err)
|
||||
defer cli.Close()
|
||||
|
||||
options := types.ContainerListOptions{
|
||||
All: true,
|
||||
}
|
||||
containers, err := cli.ContainerList(context.Background(), options)
|
||||
assert.NilError(c, err)
|
||||
var foundContainer containerPs
|
||||
for _, c := range containers {
|
||||
for _, testName := range c.Names {
|
||||
if "/"+name == testName {
|
||||
foundContainer.Names = c.Names
|
||||
foundContainer.Ports = c.Ports
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.Assert(foundContainer.Ports, checker.HasLen, 1)
|
||||
c.Assert(foundContainer.Ports[0].PrivatePort, checker.Equals, uint16(port))
|
||||
c.Assert(foundContainer.Ports[0].PublicPort, checker.NotNil)
|
||||
c.Assert(foundContainer.Ports[0].IP, checker.NotNil)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) {
|
||||
// Not supported on Windows as Windows does not support docker export
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
|
|
@ -101,7 +101,7 @@ func (s *DockerSuite) TestCreateHostConfig(c *check.C) {
|
|||
|
||||
cont := containers[0]
|
||||
c.Assert(cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none"))
|
||||
c.Assert(cont.HostConfig.PublishAllPorts, check.NotNil, check.Commentf("Expected PublishAllPorts, got false"))
|
||||
c.Assert(cont.HostConfig.PublishAllPorts, checker.True, check.Commentf("Expected PublishAllPorts, got false"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCreateWithPortRange(c *check.C) {
|
||||
|
|
|
@ -555,7 +555,6 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *check.C) {
|
|||
// inspect the network to make sure container is connected
|
||||
nr = getNetworkResource(c, nr.ID)
|
||||
c.Assert(len(nr.Containers), checker.Equals, 1)
|
||||
c.Assert(nr.Containers[containerID], check.NotNil)
|
||||
|
||||
// check if container IP matches network inspect
|
||||
ip, _, err := net.ParseCIDR(nr.Containers[containerID].IPv4Address)
|
||||
|
@ -699,8 +698,6 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *check.C) {
|
|||
c.Assert(nr.EnableIPv6, checker.Equals, false)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
|
||||
c.Assert(nr.IPAM.Config[0].Subnet, checker.NotNil)
|
||||
c.Assert(nr.IPAM.Config[0].Gateway, checker.NotNil)
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *check.C) {
|
||||
|
@ -715,8 +712,6 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *check.
|
|||
c.Assert(nr.EnableIPv6, checker.Equals, false)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
|
||||
c.Assert(nr.IPAM.Config[0].Subnet, checker.NotNil)
|
||||
c.Assert(nr.IPAM.Config[0].Gateway, checker.NotNil)
|
||||
|
||||
dockerCmd(c, "network", "rm", "test01")
|
||||
assertNwNotAvailable(c, "test01")
|
||||
|
|
Loading…
Reference in a new issue