github.com/alexandrev/docker@v1.9.0/integration-cli/docker_api_create_test.go (about) 1 package main 2 3 import ( 4 "net/http" 5 "strings" 6 7 "github.com/go-check/check" 8 ) 9 10 func (s *DockerSuite) TestApiCreateWithNotExistImage(c *check.C) { 11 name := "test" 12 config := map[string]interface{}{ 13 "Image": "test456:v1", 14 "Volumes": map[string]struct{}{"/tmp": {}}, 15 } 16 17 status, resp, err := sockRequest("POST", "/containers/create?name="+name, config) 18 c.Assert(err, check.IsNil) 19 c.Assert(status, check.Equals, http.StatusNotFound) 20 expected := "No such image: test456:v1" 21 if !strings.Contains(string(resp), expected) { 22 c.Fatalf("expected: %s, got: %s", expected, string(resp)) 23 } 24 25 config2 := map[string]interface{}{ 26 "Image": "test456", 27 "Volumes": map[string]struct{}{"/tmp": {}}, 28 } 29 30 status, resp, err = sockRequest("POST", "/containers/create?name="+name, config2) 31 c.Assert(err, check.IsNil) 32 c.Assert(status, check.Equals, http.StatusNotFound) 33 expected = "No such image: test456:latest" 34 if !strings.Contains(string(resp), expected) { 35 c.Fatalf("expected: %s, got: %s", expected, string(resp)) 36 } 37 38 }