github.com/jandre/docker@v1.7.0/integration-cli/docker_api_exec_test.go (about)

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