mirror of https://github.com/docker/docs.git
Merge pull request #10793 from ahmetalpbalkan/win-cli/TestExportContainerAndImportImage-fix
integration-cli: use cmd.Stdin instead of cat/tee for TestExportContainerAndImportImage
This commit is contained in:
commit
7e9dd94376
|
@ -1,9 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -23,15 +22,13 @@ func TestExportContainerAndImportImage(t *testing.T) {
|
|||
t.Fatalf("output should've been a container id: %s %s ", cleanedContainerID, err)
|
||||
}
|
||||
|
||||
exportCmdTemplate := `%v export %v > /tmp/testexp.tar`
|
||||
exportCmdFinal := fmt.Sprintf(exportCmdTemplate, dockerBinary, cleanedContainerID)
|
||||
exportCmd := exec.Command("bash", "-c", exportCmdFinal)
|
||||
exportCmd := exec.Command(dockerBinary, "export", cleanedContainerID)
|
||||
if out, _, err = runCommandWithOutput(exportCmd); err != nil {
|
||||
t.Fatalf("failed to export container: %s, %v", out, err)
|
||||
}
|
||||
|
||||
importCmdFinal := `cat /tmp/testexp.tar | docker import - repo/testexp:v1`
|
||||
importCmd := exec.Command("bash", "-c", importCmdFinal)
|
||||
importCmd := exec.Command(dockerBinary, "import", "-", "repo/testexp:v1")
|
||||
importCmd.Stdin = strings.NewReader(out)
|
||||
out, _, err = runCommandWithOutput(importCmd)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to import image: %s, %v", out, err)
|
||||
|
@ -47,8 +44,6 @@ func TestExportContainerAndImportImage(t *testing.T) {
|
|||
deleteContainer(cleanedContainerID)
|
||||
deleteImages("repo/testexp:v1")
|
||||
|
||||
os.Remove("/tmp/testexp.tar")
|
||||
|
||||
logDone("export - export a container")
|
||||
logDone("import - import an image")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue