docker_api_exec_test.go 684 B

12345678910111213141516171819202122232425
  1. // +build !test_no_exec
  2. package main
  3. import (
  4. "bytes"
  5. "fmt"
  6. "os/exec"
  7. "github.com/go-check/check"
  8. )
  9. // Regression test for #9414
  10. func (s *DockerSuite) TestExecApiCreateNoCmd(c *check.C) {
  11. name := "exec_test"
  12. runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
  13. if out, _, err := runCommandWithOutput(runCmd); err != nil {
  14. c.Fatal(out, err)
  15. }
  16. _, body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": nil})
  17. if err == nil || !bytes.Contains(body, []byte("No exec command specified")) {
  18. c.Fatalf("Expected error when creating exec command with no Cmd specified: %q", err)
  19. }
  20. }