mirror of https://github.com/docker/cli.git
Merge pull request #907 from dnephin/add-more-container-copy-tests
Add more container cp tests
This commit is contained in:
commit
c9303404d4
|
@ -3,6 +3,7 @@ package container
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -111,6 +112,33 @@ func TestRunCopyFromContainerToFilesystemMissingDestinationDirectory(t *testing.
|
||||||
testutil.ErrorContains(t, err, destDir.Join("missing"))
|
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) {
|
func TestSplitCpArg(t *testing.T) {
|
||||||
var testcases = []struct {
|
var testcases = []struct {
|
||||||
doc string
|
doc string
|
||||||
|
|
Loading…
Reference in New Issue