예제 #1
0
// regression gh14320
func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) {
	client, err := request.NewClient(daemonHost())
	c.Assert(err, checker.IsNil)
	req, err := request.New(daemonHost(), "/containers/doesnotexist/attach", request.Method(http.MethodPost))
	resp, err := client.Do(req)
	// connection will shutdown, err should be "persistent connection closed"
	c.Assert(resp.StatusCode, checker.Equals, http.StatusNotFound)
	content, err := testutil.ReadBody(resp.Body)
	c.Assert(err, checker.IsNil)
	expected := "No such container: doesnotexist\r\n"
	c.Assert(string(content), checker.Equals, expected)
}
예제 #2
0
// regression gh14320
func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) {
	req, client, err := newRequestClient("POST", "/containers/doesnotexist/attach", nil, "", "")
	c.Assert(err, checker.IsNil)

	resp, err := client.Do(req)
	// connection will shutdown, err should be "persistent connection closed"
	c.Assert(err, checker.NotNil) // Server shutdown connection

	body, err := testutil.ReadBody(resp.Body)
	c.Assert(err, checker.IsNil)
	c.Assert(resp.StatusCode, checker.Equals, http.StatusNotFound)
	expected := "No such container: doesnotexist\r\n"
	c.Assert(string(body), checker.Equals, expected)
}