1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/docker_api_exec_test.go
Jessica Frazelle ecdbc1a0af Add build flag to exec test.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2015-01-23 16:18:39 -08:00

27 lines
738 B
Go

// +build !test_no_exec
package main
import (
"bytes"
"fmt"
"os/exec"
"testing"
)
// Regression test for #9414
func TestExecApiCreateNoCmd(t *testing.T) {
defer deleteAllContainers()
name := "exec_test"
runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
if out, _, err := runCommandWithOutput(runCmd); err != nil {
t.Fatal(out, err)
}
body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": nil})
if err == nil || !bytes.Contains(body, []byte("No exec command specified")) {
t.Fatalf("Expected error when creating exec command with no Cmd specified: %q", err)
}
logDone("exec create API - returns error when missing Cmd")
}