github.com/varun06/docker@v1.6.0-rc2/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 "os/exec" 9 "testing" 10 ) 11 12 // Regression test for #9414 13 func TestExecApiCreateNoCmd(t *testing.T) { 14 defer deleteAllContainers() 15 name := "exec_test" 16 runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") 17 if out, _, err := runCommandWithOutput(runCmd); err != nil { 18 t.Fatal(out, err) 19 } 20 21 body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": nil}) 22 if err == nil || !bytes.Contains(body, []byte("No exec command specified")) { 23 t.Fatalf("Expected error when creating exec command with no Cmd specified: %q", err) 24 } 25 26 logDone("exec create API - returns error when missing Cmd") 27 }