2014-03-31 19:31:21 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestImportDisplay(t *testing.T) {
|
2015-02-14 10:27:06 +00:00
|
|
|
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
|
|
|
|
out, _, err := runCommandWithOutput(runCmd)
|
2014-09-12 17:10:42 +00:00
|
|
|
if err != nil {
|
2015-02-14 10:27:06 +00:00
|
|
|
t.Fatal("failed to create a container", out, err)
|
2014-09-12 17:10:42 +00:00
|
|
|
}
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2015-02-14 10:27:06 +00:00
|
|
|
defer deleteContainer(cleanedContainerID)
|
|
|
|
|
|
|
|
out, _, err = runCommandPipelineWithOutput(
|
|
|
|
exec.Command(dockerBinary, "export", cleanedContainerID),
|
|
|
|
exec.Command(dockerBinary, "import", "-"),
|
|
|
|
)
|
2014-09-12 13:51:21 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("import failed with errors: %v, output: %q", err, out)
|
|
|
|
}
|
2014-03-31 19:31:21 +00:00
|
|
|
|
2015-02-14 10:27:06 +00: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 19:31:21 +00:00
|
|
|
}
|
2015-02-14 10:27:06 +00:00
|
|
|
image := strings.TrimSpace(out)
|
|
|
|
defer deleteImages(image)
|
2014-03-31 19:31:21 +00:00
|
|
|
|
2015-02-14 10:27:06 +00: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 16:05:49 +00:00
|
|
|
|
2015-02-14 10:27:06 +00:00
|
|
|
logDone("import - display is fine, imported image runs")
|
2014-03-31 19:31:21 +00:00
|
|
|
}
|