gopkg.in/docker/docker.v1@v1.13.1/integration-cli/docker_api_resize_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  	"strings"
     6  
     7  	"github.com/docker/docker/pkg/integration/checker"
     8  	"github.com/go-check/check"
     9  )
    10  
    11  func (s *DockerSuite) TestResizeAPIResponse(c *check.C) {
    12  	out, _ := runSleepingContainer(c, "-d")
    13  	cleanedContainerID := strings.TrimSpace(out)
    14  
    15  	endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
    16  	status, _, err := sockRequest("POST", endpoint, nil)
    17  	c.Assert(status, check.Equals, http.StatusOK)
    18  	c.Assert(err, check.IsNil)
    19  }
    20  
    21  func (s *DockerSuite) TestResizeAPIHeightWidthNoInt(c *check.C) {
    22  	out, _ := runSleepingContainer(c, "-d")
    23  	cleanedContainerID := strings.TrimSpace(out)
    24  
    25  	endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar"
    26  	status, _, err := sockRequest("POST", endpoint, nil)
    27  	c.Assert(status, check.Equals, http.StatusInternalServerError)
    28  	c.Assert(err, check.IsNil)
    29  }
    30  
    31  func (s *DockerSuite) TestResizeAPIResponseWhenContainerNotStarted(c *check.C) {
    32  	out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
    33  	cleanedContainerID := strings.TrimSpace(out)
    34  
    35  	// make sure the exited container is not running
    36  	dockerCmd(c, "wait", cleanedContainerID)
    37  
    38  	endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
    39  	status, body, err := sockRequest("POST", endpoint, nil)
    40  	c.Assert(status, check.Equals, http.StatusInternalServerError)
    41  	c.Assert(err, check.IsNil)
    42  
    43  	c.Assert(getErrorMessage(c, body), checker.Contains, "is not running", check.Commentf("resize should fail with message 'Container is not running'"))
    44  }