From 07cb69e9bce40495b489905e6795dc048232b324 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 27 Feb 2018 16:38:02 -0500 Subject: [PATCH] Add more container cp tests Signed-off-by: Daniel Nephin --- cli/command/container/cp_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cli/command/container/cp_test.go b/cli/command/container/cp_test.go index db7760c4b2..ce4430746e 100644 --- a/cli/command/container/cp_test.go +++ b/cli/command/container/cp_test.go @@ -3,6 +3,7 @@ package container import ( "io" "io/ioutil" + "os" "runtime" "strings" "testing" @@ -111,6 +112,33 @@ func TestRunCopyFromContainerToFilesystemMissingDestinationDirectory(t *testing. testutil.ErrorContains(t, err, destDir.Join("missing")) } +func TestRunCopyToContainerFromFileWithTrailingSlash(t *testing.T) { + srcFile := fs.NewFile(t, t.Name()) + defer srcFile.Remove() + + options := copyOptions{ + source: srcFile.Path() + string(os.PathSeparator), + destination: "container:/path", + } + cli := test.NewFakeCli(&fakeClient{}) + err := runCopy(cli, options) + testutil.ErrorContains(t, err, "not a directory") +} + +func TestRunCopyToContainerSourceDoesNotExist(t *testing.T) { + options := copyOptions{ + source: "/does/not/exist", + destination: "container:/path", + } + cli := test.NewFakeCli(&fakeClient{}) + err := runCopy(cli, options) + expected := "no such file or directory" + if runtime.GOOS == "windows" { + expected = "cannot find the file specified" + } + testutil.ErrorContains(t, err, expected) +} + func TestSplitCpArg(t *testing.T) { var testcases = []struct { doc string