78a272ce |
package main
import ( |
27fccdba |
"net/http" |
78a272ce |
"strings" |
dc944ea7 |
"github.com/go-check/check" |
78a272ce |
)
|
dc944ea7 |
func (s *DockerSuite) TestResizeApiResponse(c *check.C) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
5c295460 |
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") |
475c6531 |
cleanedContainerID := strings.TrimSpace(out) |
78a272ce |
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" |
c7845e27 |
status, _, err := sockRequest("POST", endpoint, nil)
c.Assert(status, check.Equals, http.StatusOK)
c.Assert(err, check.IsNil) |
78a272ce |
}
|
dc944ea7 |
func (s *DockerSuite) TestResizeApiHeightWidthNoInt(c *check.C) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
5c295460 |
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") |
3341f3a3 |
cleanedContainerID := strings.TrimSpace(out)
endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar" |
27fccdba |
status, _, err := sockRequest("POST", endpoint, nil) |
c7845e27 |
c.Assert(status, check.Equals, http.StatusInternalServerError)
c.Assert(err, check.IsNil) |
3341f3a3 |
}
|
dc944ea7 |
func (s *DockerSuite) TestResizeApiResponseWhenContainerNotStarted(c *check.C) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
5c295460 |
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") |
475c6531 |
cleanedContainerID := strings.TrimSpace(out) |
78a272ce |
|
4ddc721f |
// make sure the exited container is not running |
5c295460 |
dockerCmd(c, "wait", cleanedContainerID) |
78a272ce |
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40" |
c7845e27 |
status, body, err := sockRequest("POST", endpoint, nil)
c.Assert(status, check.Equals, http.StatusInternalServerError)
c.Assert(err, check.IsNil)
|
78a272ce |
if !strings.Contains(string(body), "Cannot resize container") && !strings.Contains(string(body), cleanedContainerID) { |
dc944ea7 |
c.Fatalf("resize should fail with message 'Cannot resize container' but instead received %s", string(body)) |
78a272ce |
}
} |