Merge pull request #10780 from estesp/test-bogus-link

Fix daemon.Get() error handling with --link setup. Add test.
This commit is contained in:
Jessie Frazelle
2015-02-16 11:22:21 -08:00
2 changed files with 29 additions and 14 deletions
+16
View File
@@ -64,6 +64,22 @@ func TestLinksPingUnlinkedContainers(t *testing.T) {
logDone("links - ping unlinked container")
}
// Test for appropriate error when calling --link with an invalid target container
func TestLinksInvalidContainerTarget(t *testing.T) {
runCmd := exec.Command(dockerBinary, "run", "--link", "bogus:alias", "busybox", "true")
out, _, err := runCommandWithOutput(runCmd)
if err == nil {
t.Fatal("an invalid container target should produce an error")
}
if !strings.Contains(out, "Could not get container") {
t.Fatal("error output expected 'Could not get container', but got %q instead; err: %v", out, err)
}
deleteAllContainers()
logDone("links - linking to non-existent container should not work")
}
func TestLinksPingLinkedContainers(t *testing.T) {
var out string
out, _, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")