MCPcopy Index your code
hub / github.com/docker/cli / TestCopyFromContainerReportsDirectorySize

Function TestCopyFromContainerReportsDirectorySize

cli/command/container/cp_test.go:382–412  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

380}
381
382func TestCopyFromContainerReportsDirectorySize(t *testing.T) {
383 // When copying a directory from a container, cpRes.Stat.Mode.IsDir() is true,
384 // so reportedSize falls back to copiedSize (the tar stream bytes).
385 srcDir := fs.NewDir(t, "cp-test-fromdir",
386 fs.WithFile("file1", "hello"))
387
388 destDir := fs.NewDir(t, "cp-test-fromdir-dest")
389
390 fakeCli := test.NewFakeCli(&fakeClient{
391 containerCopyFromFunc: func(ctr, srcPath string) (client.CopyFromContainerResult, error) {
392 readCloser, err := archive.Tar(srcDir.Path(), compression.None)
393 return client.CopyFromContainerResult{
394 Content: readCloser,
395 Stat: container.PathStat{
396 Name: "mydir",
397 Mode: os.ModeDir | 0o755,
398 },
399 }, err
400 },
401 })
402 err := runCopy(context.TODO(), fakeCli, copyOptions{
403 source: "container:/mydir",
404 destination: destDir.Path(),
405 })
406 assert.NilError(t, err)
407 errOut := fakeCli.ErrBuffer().String()
408 assert.Check(t, is.Contains(errOut, "Successfully copied"))
409 // For directories from container, content size is unknown so
410 // reportedSize == copiedSize and "(transferred ...)" is omitted.
411 assert.Check(t, !strings.Contains(errOut, "(transferred"))
412}
413
414func TestCopyToContainerStdinReportsTransferredSize(t *testing.T) {
415 // When copying from stdin, content size is unknown.

Callers

nothing calls this directly

Calls 5

ErrBufferMethod · 0.95
runCopyFunction · 0.85
ContainsMethod · 0.80
PathMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…