2014-10-24 04:30:18 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2015-04-14 01:30:07 +08:00
|
|
|
"net/http"
|
2014-10-24 04:30:18 +08:00
|
|
|
"strings"
|
2015-04-19 00:46:47 +08:00
|
|
|
|
2015-10-13 20:01:58 +08:00
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
2015-04-19 00:46:47 +08:00
|
|
|
"github.com/go-check/check"
|
2014-10-24 04:30:18 +08:00
|
|
|
)
|
|
|
|
|
|
2015-04-19 00:46:47 +08:00
|
|
|
func (s *DockerSuite) TestResizeApiResponse(c *check.C) {
|
2016-02-03 10:51:42 +08:00
|
|
|
out, _ := runSleepingContainer(c, "-d")
|
2015-04-06 21:21:18 +08:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-10-24 04:30:18 +08:00
|
|
|
|
|
|
|
|
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
|
2015-04-21 05:03:56 +08:00
|
|
|
status, _, err := sockRequest("POST", endpoint, nil)
|
|
|
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
|
|
|
c.Assert(err, check.IsNil)
|
2014-10-24 04:30:18 +08:00
|
|
|
}
|
|
|
|
|
|
2015-04-19 00:46:47 +08:00
|
|
|
func (s *DockerSuite) TestResizeApiHeightWidthNoInt(c *check.C) {
|
2016-02-03 10:51:42 +08:00
|
|
|
out, _ := runSleepingContainer(c, "-d")
|
2015-04-13 14:36:04 +08:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
|
|
|
|
|
|
|
|
|
endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar"
|
2015-04-14 01:30:07 +08:00
|
|
|
status, _, err := sockRequest("POST", endpoint, nil)
|
2015-04-21 05:03:56 +08:00
|
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
|
|
|
c.Assert(err, check.IsNil)
|
2015-04-13 14:36:04 +08:00
|
|
|
}
|
|
|
|
|
|
2015-04-19 00:46:47 +08:00
|
|
|
func (s *DockerSuite) TestResizeApiResponseWhenContainerNotStarted(c *check.C) {
|
2015-07-14 14:35:36 +08:00
|
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
2015-04-06 21:21:18 +08:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-10-24 04:30:18 +08:00
|
|
|
|
2015-04-10 15:09:26 +08:00
|
|
|
// make sure the exited container is not running
|
2015-07-14 14:35:36 +08:00
|
|
|
dockerCmd(c, "wait", cleanedContainerID)
|
2014-10-24 04:30:18 +08:00
|
|
|
|
|
|
|
|
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
|
2015-04-21 05:03:56 +08:00
|
|
|
status, body, err := sockRequest("POST", endpoint, nil)
|
|
|
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
|
|
2016-05-21 19:56:04 +08:00
|
|
|
c.Assert(getErrorMessage(c, body), checker.Contains, "is not running", check.Commentf("resize should fail with message 'Container is not running'"))
|
2014-10-24 04:30:18 +08:00
|
|
|
}
|