2014-03-31 15:31:21 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestImportDisplay(t *testing.T) {
|
2015-02-14 05:27:06 -05:00
|
|
|
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
|
|
|
|
out, _, err := runCommandWithOutput(runCmd)
|
2014-09-12 13:10:42 -04:00
|
|
|
if err != nil {
|
2015-02-14 05:27:06 -05:00
|
|
|
t.Fatal("failed to create a container", out, err)
|
2014-09-12 13:10:42 -04:00
|
|
|
}
|
2015-02-14 05:27:06 -05:00
|
|
|
cleanedContainerID := stripTrailingCharacters(out)
|
|
|
|
defer deleteContainer(cleanedContainerID)
|
|
|
|
|
|
|
|
out, _, err = runCommandPipelineWithOutput(
|
|
|
|
exec.Command(dockerBinary, "export", cleanedContainerID),
|
|
|
|
exec.Command(dockerBinary, "import", "-"),
|
|
|
|
)
|
2014-09-12 09:51:21 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("import failed with errors: %v, output: %q", err, out)
|
|
|
|
}
|
2014-03-31 15:31:21 -04:00
|
|
|
|
2015-02-14 05:27:06 -05:00
|
|
|
if n := strings.Count(out, "\n"); n != 1 {
|
|
|
|
t.Fatalf("display is messed up: %d '\\n' instead of 1:\n%s", n, out)
|
2014-03-31 15:31:21 -04:00
|
|
|
}
|
2015-02-14 05:27:06 -05:00
|
|
|
image := strings.TrimSpace(out)
|
|
|
|
defer deleteImages(image)
|
2014-03-31 15:31:21 -04:00
|
|
|
|
2015-02-14 05:27:06 -05:00
|
|
|
runCmd = exec.Command(dockerBinary, "run", "--rm", image, "true")
|
|
|
|
out, _, err = runCommandWithOutput(runCmd)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("failed to create a container", out, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if out != "" {
|
|
|
|
t.Fatalf("command output should've been nothing, was %q", out)
|
|
|
|
}
|
2014-11-17 11:05:49 -05:00
|
|
|
|
2015-02-14 05:27:06 -05:00
|
|
|
logDone("import - display is fine, imported image runs")
|
2014-03-31 15:31:21 -04:00
|
|
|
}
|