github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/integration-cli/docker_api_resize_test.go (about) 1 package main 2 3 import ( 4 "net/http" 5 "strings" 6 7 "github.com/docker/docker/integration-cli/checker" 8 "github.com/docker/docker/integration-cli/request" 9 "github.com/go-check/check" 10 ) 11 12 func (s *DockerSuite) TestResizeAPIResponse(c *check.C) { 13 out, _ := runSleepingContainer(c, "-d") 14 cleanedContainerID := strings.TrimSpace(out) 15 16 endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" 17 status, _, err := request.SockRequest("POST", endpoint, nil, daemonHost()) 18 c.Assert(status, check.Equals, http.StatusOK) 19 c.Assert(err, check.IsNil) 20 } 21 22 func (s *DockerSuite) TestResizeAPIHeightWidthNoInt(c *check.C) { 23 out, _ := runSleepingContainer(c, "-d") 24 cleanedContainerID := strings.TrimSpace(out) 25 26 endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar" 27 status, _, err := request.SockRequest("POST", endpoint, nil, daemonHost()) 28 c.Assert(status, check.Equals, http.StatusInternalServerError) 29 c.Assert(err, check.IsNil) 30 } 31 32 func (s *DockerSuite) TestResizeAPIResponseWhenContainerNotStarted(c *check.C) { 33 out, _ := dockerCmd(c, "run", "-d", "busybox", "true") 34 cleanedContainerID := strings.TrimSpace(out) 35 36 // make sure the exited container is not running 37 dockerCmd(c, "wait", cleanedContainerID) 38 39 endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" 40 status, body, err := request.SockRequest("POST", endpoint, nil, daemonHost()) 41 c.Assert(status, check.Equals, http.StatusInternalServerError) 42 c.Assert(err, check.IsNil) 43 44 c.Assert(getErrorMessage(c, body), checker.Contains, "is not running", check.Commentf("resize should fail with message 'Container is not running'")) 45 }