docker_api_resize_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package main
  2. import (
  3. "net/http"
  4. "strings"
  5. "github.com/docker/docker/pkg/integration/checker"
  6. "github.com/go-check/check"
  7. )
  8. func (s *DockerSuite) TestResizeApiResponse(c *check.C) {
  9. out, _ := runSleepingContainer(c, "-d")
  10. cleanedContainerID := strings.TrimSpace(out)
  11. endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
  12. status, _, err := sockRequest("POST", endpoint, nil)
  13. c.Assert(status, check.Equals, http.StatusOK)
  14. c.Assert(err, check.IsNil)
  15. }
  16. func (s *DockerSuite) TestResizeApiHeightWidthNoInt(c *check.C) {
  17. out, _ := runSleepingContainer(c, "-d")
  18. cleanedContainerID := strings.TrimSpace(out)
  19. endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar"
  20. status, _, err := sockRequest("POST", endpoint, nil)
  21. c.Assert(status, check.Equals, http.StatusInternalServerError)
  22. c.Assert(err, check.IsNil)
  23. }
  24. func (s *DockerSuite) TestResizeApiResponseWhenContainerNotStarted(c *check.C) {
  25. out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
  26. cleanedContainerID := strings.TrimSpace(out)
  27. // make sure the exited container is not running
  28. dockerCmd(c, "wait", cleanedContainerID)
  29. endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
  30. status, body, err := sockRequest("POST", endpoint, nil)
  31. c.Assert(status, check.Equals, http.StatusInternalServerError)
  32. c.Assert(err, check.IsNil)
  33. c.Assert(getErrorMessage(c, body), checker.Contains, "is not running", check.Commentf("resize should fail with message 'Container is not running'"))
  34. }