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

Function TestContainerExportOutputToFile

cli/command/container/export_test.go:13–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestContainerExportOutputToFile(t *testing.T) {
14 dir := fs.NewDir(t, "export-test")
15 defer dir.Remove()
16
17 cli := test.NewFakeCli(&fakeClient{
18 containerExportFunc: func(container string) (client.ContainerExportResult, error) {
19 // FIXME(thaJeztah): how to mock this?
20 return mockContainerExportResult("bar"), nil
21 },
22 })
23 cmd := newExportCommand(cli)
24 cmd.SetOut(io.Discard)
25 cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"})
26 assert.NilError(t, cmd.Execute())
27
28 expected := fs.Expected(t,
29 fs.WithFile("foo", "bar", fs.MatchAnyFileMode),
30 )
31
32 assert.Assert(t, fs.Equal(dir.Path(), expected))
33}
34
35func TestContainerExportOutputToIrregularFile(t *testing.T) {
36 cli := test.NewFakeCli(&fakeClient{

Callers

nothing calls this directly

Calls 6

SetArgsMethod · 0.80
newExportCommandFunction · 0.70
RemoveMethod · 0.65
PathMethod · 0.65
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…