mirror of https://github.com/docker/docs.git
Cleanup errorOut resp run tests
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
This commit is contained in:
parent
842d4b6b0a
commit
66ac7420a9
|
@ -141,8 +141,6 @@ func TestRunPingGoogle(t *testing.T) {
|
||||||
t.Fatalf("failed to run container: %v, output: %q", err, out)
|
t.Fatalf("failed to run container: %v, output: %q", err, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
errorOut(err, t, "container should've been able to ping 8.8.8.8")
|
|
||||||
|
|
||||||
deleteAllContainers()
|
deleteAllContainers()
|
||||||
|
|
||||||
logDone("run - ping 8.8.8.8")
|
logDone("run - ping 8.8.8.8")
|
||||||
|
@ -152,11 +150,8 @@ func TestRunPingGoogle(t *testing.T) {
|
||||||
// some versions of lxc might make this test fail
|
// some versions of lxc might make this test fail
|
||||||
func TestRunExitCodeZero(t *testing.T) {
|
func TestRunExitCodeZero(t *testing.T) {
|
||||||
runCmd := exec.Command(dockerBinary, "run", "busybox", "true")
|
runCmd := exec.Command(dockerBinary, "run", "busybox", "true")
|
||||||
exitCode, err := runCommand(runCmd)
|
if out, _, err := runCommandWithOutput(runCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("%s", err))
|
t.Errorf("container should've exited with exit code 0: %s, %v", out, err)
|
||||||
|
|
||||||
if exitCode != 0 {
|
|
||||||
t.Errorf("container should've exited with exit code 0")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAllContainers()
|
deleteAllContainers()
|
||||||
|
@ -193,26 +188,31 @@ func TestRunStdinPipe(t *testing.T) {
|
||||||
out = stripTrailingCharacters(out)
|
out = stripTrailingCharacters(out)
|
||||||
|
|
||||||
inspectCmd := exec.Command(dockerBinary, "inspect", out)
|
inspectCmd := exec.Command(dockerBinary, "inspect", out)
|
||||||
inspectOut, _, err := runCommandWithOutput(inspectCmd)
|
if out, _, err := runCommandWithOutput(inspectCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("out should've been a container id: %s %s", out, inspectOut))
|
t.Fatalf("out should've been a container id: %s %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
waitCmd := exec.Command(dockerBinary, "wait", out)
|
waitCmd := exec.Command(dockerBinary, "wait", out)
|
||||||
_, _, err = runCommandWithOutput(waitCmd)
|
if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
|
t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
|
||||||
|
}
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", out)
|
logsCmd := exec.Command(dockerBinary, "logs", out)
|
||||||
containerLogs, _, err := runCommandWithOutput(logsCmd)
|
logsOut, _, err := runCommandWithOutput(logsCmd)
|
||||||
errorOut(err, t, fmt.Sprintf("error thrown while trying to get container logs: %s", err))
|
if err != nil {
|
||||||
|
t.Fatalf("error thrown while trying to get container logs: %s, %v", logsOut, err)
|
||||||
|
}
|
||||||
|
|
||||||
containerLogs = stripTrailingCharacters(containerLogs)
|
containerLogs := stripTrailingCharacters(logsOut)
|
||||||
|
|
||||||
if containerLogs != "blahblah" {
|
if containerLogs != "blahblah" {
|
||||||
t.Errorf("logs didn't print the container's logs %s", containerLogs)
|
t.Errorf("logs didn't print the container's logs %s", containerLogs)
|
||||||
}
|
}
|
||||||
|
|
||||||
rmCmd := exec.Command(dockerBinary, "rm", out)
|
rmCmd := exec.Command(dockerBinary, "rm", out)
|
||||||
_, _, err = runCommandWithOutput(rmCmd)
|
if out, _, err = runCommandWithOutput(rmCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("rm failed to remove container %s", err))
|
t.Fatalf("rm failed to remove container: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
deleteAllContainers()
|
deleteAllContainers()
|
||||||
|
|
||||||
|
@ -230,16 +230,20 @@ func TestRunDetachedContainerIDPrinting(t *testing.T) {
|
||||||
out = stripTrailingCharacters(out)
|
out = stripTrailingCharacters(out)
|
||||||
|
|
||||||
inspectCmd := exec.Command(dockerBinary, "inspect", out)
|
inspectCmd := exec.Command(dockerBinary, "inspect", out)
|
||||||
inspectOut, _, err := runCommandWithOutput(inspectCmd)
|
if inspectOut, _, err := runCommandWithOutput(inspectCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("out should've been a container id: %s %s", out, inspectOut))
|
t.Fatalf("out should've been a container id: %s %v", inspectOut, err)
|
||||||
|
}
|
||||||
|
|
||||||
waitCmd := exec.Command(dockerBinary, "wait", out)
|
waitCmd := exec.Command(dockerBinary, "wait", out)
|
||||||
_, _, err = runCommandWithOutput(waitCmd)
|
if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
|
t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
|
||||||
|
}
|
||||||
|
|
||||||
rmCmd := exec.Command(dockerBinary, "rm", out)
|
rmCmd := exec.Command(dockerBinary, "rm", out)
|
||||||
rmOut, _, err := runCommandWithOutput(rmCmd)
|
rmOut, _, err := runCommandWithOutput(rmCmd)
|
||||||
errorOut(err, t, "rm failed to remove container")
|
if err != nil {
|
||||||
|
t.Fatalf("rm failed to remove container: %s, %v", rmOut, err)
|
||||||
|
}
|
||||||
|
|
||||||
rmOut = stripTrailingCharacters(rmOut)
|
rmOut = stripTrailingCharacters(rmOut)
|
||||||
if rmOut != out {
|
if rmOut != out {
|
||||||
|
@ -267,7 +271,9 @@ func TestRunWorkingDirectory(t *testing.T) {
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "run", "--workdir", "/root", "busybox", "pwd")
|
runCmd = exec.Command(dockerBinary, "run", "--workdir", "/root", "busybox", "pwd")
|
||||||
out, _, _, err = runCommandWithStdoutStderr(runCmd)
|
out, _, _, err = runCommandWithStdoutStderr(runCmd)
|
||||||
errorOut(err, t, out)
|
if err != nil {
|
||||||
|
t.Fatal(out, err)
|
||||||
|
}
|
||||||
|
|
||||||
out = stripTrailingCharacters(out)
|
out = stripTrailingCharacters(out)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue