github.com/pritambaral/docker@v1.4.2-0.20150120174542-b2fe1b3dd952/integration-cli/docker_api_exec_test.go (about)

     1  package main
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"os/exec"
     7  	"testing"
     8  )
     9  
    10  // Regression test for #9414
    11  func TestExecApiCreateNoCmd(t *testing.T) {
    12  	defer deleteAllContainers()
    13  	name := "exec_test"
    14  	runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
    15  	if out, _, err := runCommandWithOutput(runCmd); err != nil {
    16  		t.Fatal(out, err)
    17  	}
    18  
    19  	body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": nil})
    20  	if err == nil || !bytes.Contains(body, []byte("No exec command specified")) {
    21  		t.Fatalf("Expected error when creating exec command with no Cmd specified: %q", err)
    22  	}
    23  
    24  	logDone("exec create API - returns error when missing Cmd")
    25  }