github.com/campoy/docker@v1.8.0-rc1/integration-cli/docker_api_resize_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) TestResizeApiResponse(c *check.C) { 11 out, _ := dockerCmd(c, "run", "-d", "busybox", "top") 12 cleanedContainerID := strings.TrimSpace(out) 13 14 endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" 15 status, _, err := sockRequest("POST", endpoint, nil) 16 c.Assert(status, check.Equals, http.StatusOK) 17 c.Assert(err, check.IsNil) 18 } 19 20 func (s *DockerSuite) TestResizeApiHeightWidthNoInt(c *check.C) { 21 out, _ := dockerCmd(c, "run", "-d", "busybox", "top") 22 cleanedContainerID := strings.TrimSpace(out) 23 24 endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar" 25 status, _, err := sockRequest("POST", endpoint, nil) 26 c.Assert(status, check.Equals, http.StatusInternalServerError) 27 c.Assert(err, check.IsNil) 28 } 29 30 func (s *DockerSuite) TestResizeApiResponseWhenContainerNotStarted(c *check.C) { 31 out, _ := dockerCmd(c, "run", "-d", "busybox", "true") 32 cleanedContainerID := strings.TrimSpace(out) 33 34 // make sure the exited container is not running 35 dockerCmd(c, "wait", cleanedContainerID) 36 37 endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" 38 status, body, err := sockRequest("POST", endpoint, nil) 39 c.Assert(status, check.Equals, http.StatusInternalServerError) 40 c.Assert(err, check.IsNil) 41 42 if !strings.Contains(string(body), "Cannot resize container") && !strings.Contains(string(body), cleanedContainerID) { 43 c.Fatalf("resize should fail with message 'Cannot resize container' but instead received %s", string(body)) 44 } 45 }