78a272ce |
package main
import ( |
27fccdba |
"net/http" |
78a272ce |
"strings" |
dc944ea7 |
|
710817a7 |
"github.com/docker/docker/pkg/integration/checker" |
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)
|
710817a7 |
c.Assert(string(body), checker.Contains, "is not running", check.Commentf("resize should fail with message 'Container is not running'")) |
78a272ce |
} |