mirror of https://github.com/docker/docs.git
Update ip test to parse new output
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
581e8e8918
commit
2487237937
|
@ -689,18 +689,29 @@ func TestLoopbackWhenNetworkDisabled(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoopbackOnlyExistsWhenNetworkingDisabled(t *testing.T) {
|
func TestLoopbackOnlyExistsWhenNetworkingDisabled(t *testing.T) {
|
||||||
cmd := exec.Command(dockerBinary, "run", "--net=none", "busybox", "ip", "a", "show", "up")
|
cmd := exec.Command(dockerBinary, "run", "--net=none", "busybox", "ip", "-o", "-4", "a", "show", "up")
|
||||||
out, _, err := runCommandWithOutput(cmd)
|
out, _, err := runCommandWithOutput(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, out)
|
t.Fatal(err, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
interfaces := regexp.MustCompile(`(?m)^[0-9]+: [a-zA-Z0-9]+`).FindAllString(out, -1)
|
var (
|
||||||
if len(interfaces) != 1 {
|
count = 0
|
||||||
t.Fatalf("Wrong interface count in test container: expected [*: lo], got %s", interfaces)
|
parts = strings.Split(out, "\n")
|
||||||
|
)
|
||||||
|
|
||||||
|
for _, l := range parts {
|
||||||
|
if l != "" {
|
||||||
|
count++
|
||||||
}
|
}
|
||||||
if !strings.HasSuffix(interfaces[0], ": lo") {
|
}
|
||||||
t.Fatalf("Wrong interface in test container: expected [*: lo], got %s", interfaces)
|
|
||||||
|
if count != 1 {
|
||||||
|
t.Fatalf("Wrong interface count in container %d", count)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.HasPrefix(out, "1: lo") {
|
||||||
|
t.Fatalf("Wrong interface in test container: expected [1: lo], got %s", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAllContainers()
|
deleteAllContainers()
|
||||||
|
|
Loading…
Reference in New Issue