github.com/noxiouz/docker@v0.7.3-0.20160629055221-3d231c78e8c5/integration-cli/docker_api_create_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/docker/docker/pkg/integration/checker"
     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, body, 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  	c.Assert(getErrorMessage(c, body), checker.Contains, expected)
    22  
    23  	config2 := map[string]interface{}{
    24  		"Image":   "test456",
    25  		"Volumes": map[string]struct{}{"/tmp": {}},
    26  	}
    27  
    28  	status, body, err = sockRequest("POST", "/containers/create?name="+name, config2)
    29  	c.Assert(err, check.IsNil)
    30  	c.Assert(status, check.Equals, http.StatusNotFound)
    31  	expected = "No such image: test456:latest"
    32  	c.Assert(getErrorMessage(c, body), checker.Equals, expected)
    33  
    34  	config3 := map[string]interface{}{
    35  		"Image": "sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa",
    36  	}
    37  
    38  	status, body, err = sockRequest("POST", "/containers/create?name="+name, config3)
    39  	c.Assert(err, check.IsNil)
    40  	c.Assert(status, check.Equals, http.StatusNotFound)
    41  	expected = "No such image: sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa"
    42  	c.Assert(getErrorMessage(c, body), checker.Equals, expected)
    43  
    44  }