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

Function TestCopyToContainerReportsEmptyFileSize

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

Source from the content-addressed store, hash-verified

321}
322
323func TestCopyToContainerReportsEmptyFileSize(t *testing.T) {
324 srcFile := fs.NewFile(t, "cp-test-empty", fs.WithContent(""))
325
326 fakeCli := test.NewFakeCli(&fakeClient{
327 containerStatPathFunc: func(containerID, path string) (client.ContainerStatPathResult, error) {
328 return client.ContainerStatPathResult{
329 Stat: container.PathStat{
330 Name: "tmp",
331 Mode: os.ModeDir | 0o755,
332 },
333 }, nil
334 },
335 containerCopyToFunc: func(containerID string, options client.CopyToContainerOptions) (client.CopyToContainerResult, error) {
336 _, _ = io.Copy(io.Discard, options.Content)
337 return client.CopyToContainerResult{}, nil
338 },
339 })
340 err := runCopy(context.TODO(), fakeCli, copyOptions{
341 source: srcFile.Path(),
342 destination: "container:/tmp",
343 })
344 assert.NilError(t, err)
345 errOut := fakeCli.ErrBuffer().String()
346 assert.Check(t, is.Contains(errOut, "Successfully copied 0B"))
347 assert.Check(t, is.Contains(errOut, "(transferred"))
348}
349
350func TestCopyToContainerReportsDirectorySize(t *testing.T) {
351 // Create a temp directory with files "aaa" (3 bytes) + "bbb" (3 bytes) = 6 bytes.

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…