2014-12-30 17:22:31 -05:00
|
|
|
// +build !test_no_exec
|
|
|
|
|
2014-12-01 12:16:49 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
2015-04-18 12:46:47 -04:00
|
|
|
|
|
|
|
"github.com/go-check/check"
|
2014-12-01 12:16:49 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Regression test for #9414
|
2015-04-18 12:46:47 -04:00
|
|
|
func (s *DockerSuite) TestExecApiCreateNoCmd(c *check.C) {
|
2014-12-01 12:16:49 -05:00
|
|
|
name := "exec_test"
|
|
|
|
runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
|
|
|
|
if out, _, err := runCommandWithOutput(runCmd); err != nil {
|
2015-04-18 12:46:47 -04:00
|
|
|
c.Fatal(out, err)
|
2014-12-01 12:16:49 -05:00
|
|
|
}
|
|
|
|
|
2015-04-11 17:49:14 -04:00
|
|
|
_, body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": nil})
|
2014-12-01 12:16:49 -05:00
|
|
|
if err == nil || !bytes.Contains(body, []byte("No exec command specified")) {
|
2015-04-18 12:46:47 -04:00
|
|
|
c.Fatalf("Expected error when creating exec command with no Cmd specified: %q", err)
|
2014-12-01 12:16:49 -05:00
|
|
|
}
|
|
|
|
}
|