Files
docker-cli/cli/command/container/export_test.go
Arash Deshmeh fc1e11d46a moved integration test TestExportContainerWithOutputAndImportImage from moby/moby to docker/cli.
The integration test TestExportContainerWithOutputAndImportImage in moby/moby is the same as TestExportContainerAndImportImage,
except for the output file option. Adding a unit test to cover the output file option of the export command here allows
the removal of the redundant integration test TestExportContainerWithOutputAndImportImage.

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
2018-09-18 12:30:49 -04:00

34 lines
729 B
Go

package container
import (
"io"
"io/ioutil"
"strings"
"testing"
"github.com/docker/cli/internal/test"
"gotest.tools/assert"
"gotest.tools/fs"
)
func TestContainerExportOutputToFile(t *testing.T) {
dir := fs.NewDir(t, "export-test")
defer dir.Remove()
cli := test.NewFakeCli(&fakeClient{
containerExportFunc: func(container string) (io.ReadCloser, error) {
return ioutil.NopCloser(strings.NewReader("bar")), nil
},
})
cmd := NewExportCommand(cli)
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"})
assert.NilError(t, cmd.Execute())
expected := fs.Expected(t,
fs.WithFile("foo", "bar", fs.MatchAnyFileMode),
)
assert.Assert(t, fs.Equal(dir.Path(), expected))
}