mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fixing statusCode checks for sockRequest
Signed-off-by: Megan Kostick <mkostick@us.ibm.com>
This commit is contained in:
parent
b830b823cd
commit
c7845e27ee
12 changed files with 165 additions and 199 deletions
|
@ -17,10 +17,9 @@ func (s *DockerSuite) TestResizeApiResponse(c *check.C) {
|
|||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
|
||||
_, _, err = sockRequest("POST", endpoint, nil)
|
||||
if err != nil {
|
||||
c.Fatalf("resize Request failed %v", err)
|
||||
}
|
||||
status, _, err := sockRequest("POST", endpoint, nil)
|
||||
c.Assert(status, check.Equals, http.StatusOK)
|
||||
c.Assert(err, check.IsNil)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestResizeApiHeightWidthNoInt(c *check.C) {
|
||||
|
@ -33,12 +32,8 @@ func (s *DockerSuite) TestResizeApiHeightWidthNoInt(c *check.C) {
|
|||
|
||||
endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar"
|
||||
status, _, err := sockRequest("POST", endpoint, nil)
|
||||
if err == nil {
|
||||
c.Fatal("Expected resize Request to fail")
|
||||
}
|
||||
if status != http.StatusInternalServerError {
|
||||
c.Fatalf("Status expected %d, got %d", http.StatusInternalServerError, status)
|
||||
}
|
||||
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
||||
c.Assert(err, check.IsNil)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestResizeApiResponseWhenContainerNotStarted(c *check.C) {
|
||||
|
@ -57,10 +52,10 @@ func (s *DockerSuite) TestResizeApiResponseWhenContainerNotStarted(c *check.C) {
|
|||
}
|
||||
|
||||
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
|
||||
_, body, err := sockRequest("POST", endpoint, nil)
|
||||
if err == nil {
|
||||
c.Fatalf("resize should fail when container is not started")
|
||||
}
|
||||
status, body, err := sockRequest("POST", endpoint, nil)
|
||||
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
if !strings.Contains(string(body), "Cannot resize container") && !strings.Contains(string(body), cleanedContainerID) {
|
||||
c.Fatalf("resize should fail with message 'Cannot resize container' but instead received %s", string(body))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue