1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/docker_cli_links_test.go
cyphar 924979259e integration-cli: docker_cli_links: fixed broken tests
The tests weren't ... tested when last edited, this patch fixes
them so that they run and pass correctly.

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-05-07 01:05:15 +10:00

30 lines
954 B
Go

package main
import (
"fmt"
"os/exec"
"testing"
)
func TestPingUnlinkedContainers(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
exitCode, err := runCommand(runCmd)
if exitCode == 0 {
t.Fatal("run ping did not fail")
} else if exitCode != 1 {
errorOut(err, t, fmt.Sprintf("run ping failed with errors: %v", err))
}
}
func TestPingLinkedContainers(t *testing.T) {
var out string
out, _, _ = cmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
idA := stripTrailingCharacters(out)
out, _, _ = cmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
idB := stripTrailingCharacters(out)
cmd(t, "run", "--rm", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
cmd(t, "kill", idA)
cmd(t, "kill", idB)
deleteAllContainers()
}