forked from moby/moby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_cli_export_import_test.go
34 lines (27 loc) · 1.09 KB
/
docker_cli_export_import_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"os"
"strings"
"github.com/docker/docker/integration-cli/checker"
"github.com/go-check/check"
"gotest.tools/icmd"
)
// TODO: Move this test to docker/cli, as it is essentially the same test
// as TestExportContainerAndImportImage except output to a file.
// Used to test output flag in the export command
func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) {
testRequires(c, DaemonIsLinux)
containerID := "testexportcontainerwithoutputandimportimage"
dockerCmd(c, "run", "--name", containerID, "busybox", "true")
dockerCmd(c, "export", "--output=testexp.tar", containerID)
defer os.Remove("testexp.tar")
resultCat := icmd.RunCommand("cat", "testexp.tar")
resultCat.Assert(c, icmd.Success)
result := icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "import", "-", "repo/testexp:v1"},
Stdin: strings.NewReader(resultCat.Combined()),
})
result.Assert(c, icmd.Success)
cleanedImageID := strings.TrimSpace(result.Combined())
c.Assert(cleanedImageID, checker.Not(checker.Equals), "", check.Commentf("output should have been an image id"))
}