github.com/vincentwoo/docker@v0.7.3-0.20160116130405-82401a4b13c0/integration-cli/docker_api_create_test.go (about)

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