Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/docker/runconfig" |
| 12 | 12 |
"gotest.tools/v3/assert" |
| 13 |
- "gotest.tools/v3/assert/cmp" |
|
| 13 |
+ is "gotest.tools/v3/assert/cmp" |
|
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
type DockerCLILinksSuite struct {
|
| ... | ... |
@@ -39,11 +39,8 @@ func (s *DockerCLILinksSuite) TestLinksInvalidContainerTarget(c *testing.T) {
|
| 39 | 39 |
out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true")
|
| 40 | 40 |
|
| 41 | 41 |
// an invalid container target should produce an error |
| 42 |
- assert.Assert(c, err != nil, "out: %s", out) |
|
| 43 |
- // an invalid container target should produce an error |
|
| 44 |
- // note: convert the output to lowercase first as the error string |
|
| 45 |
- // capitalization was changed after API version 1.32 |
|
| 46 |
- assert.Assert(c, strings.Contains(strings.ToLower(out), "could not get container")) |
|
| 42 |
+ assert.Check(c, is.ErrorContains(err, "could not get container for bogus")) |
|
| 43 |
+ assert.Check(c, is.Contains(out, "could not get container")) |
|
| 47 | 44 |
} |
| 48 | 45 |
|
| 49 | 46 |
func (s *DockerCLILinksSuite) TestLinksPingLinkedContainers(c *testing.T) {
|
| ... | ... |
@@ -163,7 +160,7 @@ func (s *DockerCLILinksSuite) TestLinksHostsFilesInject(c *testing.T) {
|
| 163 | 163 |
readContainerFileWithExec(c, idOne, "/etc/hosts") |
| 164 | 164 |
contentTwo := readContainerFileWithExec(c, idTwo, "/etc/hosts") |
| 165 | 165 |
// Host is not present in updated hosts file |
| 166 |
- assert.Assert(c, strings.Contains(string(contentTwo), "onetwo")) |
|
| 166 |
+ assert.Assert(c, is.Contains(string(contentTwo), "onetwo")) |
|
| 167 | 167 |
} |
| 168 | 168 |
|
| 169 | 169 |
func (s *DockerCLILinksSuite) TestLinksUpdateOnRestart(c *testing.T) {
|
| ... | ... |
@@ -183,29 +180,29 @@ func (s *DockerCLILinksSuite) TestLinksUpdateOnRestart(c *testing.T) {
|
| 183 | 183 |
return string(matches[1]) |
| 184 | 184 |
} |
| 185 | 185 |
ip := getIP(content, "one") |
| 186 |
- assert.Equal(c, ip, realIP) |
|
| 186 |
+ assert.Check(c, is.Equal(ip, realIP)) |
|
| 187 | 187 |
|
| 188 | 188 |
ip = getIP(content, "onetwo") |
| 189 |
- assert.Equal(c, ip, realIP) |
|
| 189 |
+ assert.Check(c, is.Equal(ip, realIP)) |
|
| 190 | 190 |
|
| 191 | 191 |
dockerCmd(c, "restart", "one") |
| 192 | 192 |
realIP = inspectField(c, "one", "NetworkSettings.Networks.bridge.IPAddress") |
| 193 | 193 |
|
| 194 | 194 |
content = readContainerFileWithExec(c, id, "/etc/hosts") |
| 195 | 195 |
ip = getIP(content, "one") |
| 196 |
- assert.Equal(c, ip, realIP) |
|
| 196 |
+ assert.Check(c, is.Equal(ip, realIP)) |
|
| 197 | 197 |
|
| 198 | 198 |
ip = getIP(content, "onetwo") |
| 199 |
- assert.Equal(c, ip, realIP) |
|
| 199 |
+ assert.Check(c, is.Equal(ip, realIP)) |
|
| 200 | 200 |
} |
| 201 | 201 |
|
| 202 | 202 |
func (s *DockerCLILinksSuite) TestLinksEnvs(c *testing.T) {
|
| 203 | 203 |
testRequires(c, DaemonIsLinux) |
| 204 | 204 |
dockerCmd(c, "run", "-d", "-e", "e1=", "-e", "e2=v2", "-e", "e3=v3=v3", "--name=first", "busybox", "top") |
| 205 | 205 |
out, _ := dockerCmd(c, "run", "--name=second", "--link=first:first", "busybox", "env") |
| 206 |
- assert.Assert(c, strings.Contains(out, "FIRST_ENV_e1=\n")) |
|
| 207 |
- assert.Assert(c, strings.Contains(out, "FIRST_ENV_e2=v2")) |
|
| 208 |
- assert.Assert(c, strings.Contains(out, "FIRST_ENV_e3=v3=v3")) |
|
| 206 |
+ assert.Assert(c, is.Contains(out, "FIRST_ENV_e1=\n")) |
|
| 207 |
+ assert.Assert(c, is.Contains(out, "FIRST_ENV_e2=v2")) |
|
| 208 |
+ assert.Assert(c, is.Contains(out, "FIRST_ENV_e3=v3=v3")) |
|
| 209 | 209 |
} |
| 210 | 210 |
|
| 211 | 211 |
func (s *DockerCLILinksSuite) TestLinkShortDefinition(c *testing.T) {
|
| ... | ... |
@@ -230,16 +227,16 @@ func (s *DockerCLILinksSuite) TestLinksNetworkHostContainer(c *testing.T) {
|
| 230 | 230 |
out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true")
|
| 231 | 231 |
|
| 232 | 232 |
// Running container linking to a container with --net host should have failed |
| 233 |
- assert.Assert(c, err != nil, "out: %s", out) |
|
| 233 |
+ assert.Check(c, err != nil, "out: %s", out) |
|
| 234 | 234 |
// Running container linking to a container with --net host should have failed |
| 235 |
- assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error())) |
|
| 235 |
+ assert.Check(c, is.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error())) |
|
| 236 | 236 |
} |
| 237 | 237 |
|
| 238 | 238 |
func (s *DockerCLILinksSuite) TestLinksEtcHostsRegularFile(c *testing.T) {
|
| 239 | 239 |
testRequires(c, DaemonIsLinux, NotUserNamespace) |
| 240 | 240 |
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts") |
| 241 | 241 |
// /etc/hosts should be a regular file |
| 242 |
- assert.Assert(c, cmp.Regexp("^-.+\n$", out))
|
|
| 242 |
+ assert.Assert(c, is.Regexp("^-.+\n$", out))
|
|
| 243 | 243 |
} |
| 244 | 244 |
|
| 245 | 245 |
func (s *DockerCLILinksSuite) TestLinksMultipleWithSameName(c *testing.T) {
|