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

Function TestCopyToContainerReportsDirectorySize

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

Source from the content-addressed store, hash-verified

348}
349
350func TestCopyToContainerReportsDirectorySize(t *testing.T) {
351 // Create a temp directory with files "aaa" (3 bytes) + "bbb" (3 bytes) = 6 bytes.
352 // The TAR archive is much larger, but the success message should report 6B.
353 srcDir := fs.NewDir(t, "cp-test-dir",
354 fs.WithFile("aaa", "aaa"),
355 fs.WithFile("bbb", "bbb"),
356 )
357
358 fakeCli := test.NewFakeCli(&fakeClient{
359 containerStatPathFunc: func(containerID, path string) (client.ContainerStatPathResult, error) {
360 return client.ContainerStatPathResult{
361 Stat: container.PathStat{
362 Name: "tmp",
363 Mode: os.ModeDir | 0o755,
364 },
365 }, nil
366 },
367 containerCopyToFunc: func(containerID string, options client.CopyToContainerOptions) (client.CopyToContainerResult, error) {
368 _, _ = io.Copy(io.Discard, options.Content)
369 return client.CopyToContainerResult{}, nil
370 },
371 })
372 err := runCopy(context.TODO(), fakeCli, copyOptions{
373 source: srcDir.Path() + string(os.PathSeparator),
374 destination: "container:/tmp",
375 })
376 assert.NilError(t, err)
377 errOut := fakeCli.ErrBuffer().String()
378 assert.Check(t, is.Contains(errOut, "Successfully copied 6B"))
379 assert.Check(t, is.Contains(errOut, "(transferred"))
380}
381
382func TestCopyFromContainerReportsDirectorySize(t *testing.T) {
383 // When copying a directory from a container, cpRes.Stat.Mode.IsDir() is true,

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…