From 497f4207e979ee57cdcc2efb35cbc4793c6c6f6a Mon Sep 17 00:00:00 2001 From: unclejack Date: Sat, 19 Oct 2013 02:06:25 +0300 Subject: [PATCH] test: error out when bind mount source doesn't exist This adds a test to verify that the server is checking whether the path to be bind mounted actually exists on the server. Upstream-commit: 35430e89201972d877ba01405f966882a1d3888a Component: engine --- components/engine/commands_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/components/engine/commands_test.go b/components/engine/commands_test.go index e33ba9c7cc..b38ed33132 100644 --- a/components/engine/commands_test.go +++ b/components/engine/commands_test.go @@ -679,3 +679,22 @@ func TestRunErrorBindMountRootSource(t *testing.T) { <-c }) } + +// Expected behaviour: error out when attempting to bind mount non-existing source paths +func TestRunErrorBindNonExistingSource(t *testing.T) { + + cli := NewDockerCli(nil, nil, ioutil.Discard, testDaemonProto, testDaemonAddr) + defer cleanup(globalRuntime) + + c := make(chan struct{}) + go func() { + defer close(c) + if err := cli.CmdRun("-v", "/i/dont/exist:/tmp", unitTestImageID, "echo 'should fail'"); err == nil { + t.Fatal("should have failed to run when using /i/dont/exist as a source for the bind mount") + } + }() + + setTimeout(t, "CmdRun timed out", 5*time.Second, func() { + <-c + }) +}