Fixing statusCode checks for sockRequest
Signed-off-by: Megan Kostick <mkostick@us.ibm.com> Upstream-commit: c7845e27ee2b0462b01d043caeb771f21d5e4ac7 Component: engine
This commit is contained in:
@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user