From 2a3225eb82274d245c25fc6191945dde1f25f668 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Thu, 15 Jan 2015 11:03:46 -0800 Subject: [PATCH] Test for links names in ps --no-trunc Signed-off-by: Alexander Morozov --- integration-cli/docker_cli_ps_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/integration-cli/docker_cli_ps_test.go b/integration-cli/docker_cli_ps_test.go index 89dbf23cde..b92c80416c 100644 --- a/integration-cli/docker_cli_ps_test.go +++ b/integration-cli/docker_cli_ps_test.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os/exec" + "reflect" "strconv" "strings" "testing" @@ -539,3 +540,29 @@ func TestPsRightTagName(t *testing.T) { } logDone("ps - right tags for containers") } + +func TestPsLinkedWithNoTrunc(t *testing.T) { + defer deleteAllContainers() + if out, err := exec.Command(dockerBinary, "run", "--name=first", "-d", "busybox", "top").CombinedOutput(); err != nil { + t.Fatalf("Output: %s, err: %s", out, err) + } + if out, err := exec.Command(dockerBinary, "run", "--name=second", "--link=first:first", "-d", "busybox", "top").CombinedOutput(); err != nil { + t.Fatalf("Output: %s, err: %s", out, err) + } + out, err := exec.Command(dockerBinary, "ps", "--no-trunc").CombinedOutput() + if err != nil { + t.Fatalf("Output: %s, err: %s", out, err) + } + lines := strings.Split(strings.TrimSpace(string(out)), "\n") + // strip header + lines = lines[1:] + expected := []string{"second", "first,second/first"} + var names []string + for _, l := range lines { + fields := strings.Fields(l) + names = append(names, fields[len(fields)-1]) + } + if !reflect.DeepEqual(expected, names) { + t.Fatalf("Expected array: %v, got: %v", expected, names) + } +}