github.com/nullne/docker@v1.13.0-rc1/integration-cli/docker_api_info_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/docker/docker/pkg/integration/checker"
     7  	"github.com/go-check/check"
     8  )
     9  
    10  func (s *DockerSuite) TestInfoAPI(c *check.C) {
    11  	endpoint := "/info"
    12  
    13  	status, body, err := sockRequest("GET", endpoint, nil)
    14  	c.Assert(status, checker.Equals, http.StatusOK)
    15  	c.Assert(err, checker.IsNil)
    16  
    17  	// always shown fields
    18  	stringsToCheck := []string{
    19  		"ID",
    20  		"Containers",
    21  		"ContainersRunning",
    22  		"ContainersPaused",
    23  		"ContainersStopped",
    24  		"Images",
    25  		"LoggingDriver",
    26  		"OperatingSystem",
    27  		"NCPU",
    28  		"OSType",
    29  		"Architecture",
    30  		"MemTotal",
    31  		"KernelVersion",
    32  		"Driver",
    33  		"ServerVersion",
    34  		"SecurityOptions"}
    35  
    36  	out := string(body)
    37  	for _, linePrefix := range stringsToCheck {
    38  		c.Assert(out, checker.Contains, linePrefix)
    39  	}
    40  }
    41  
    42  func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) {
    43  	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
    44  	endpoint := "/v1.20/info"
    45  
    46  	status, body, err := sockRequest("GET", endpoint, nil)
    47  	c.Assert(status, checker.Equals, http.StatusOK)
    48  	c.Assert(err, checker.IsNil)
    49  
    50  	out := string(body)
    51  	c.Assert(out, checker.Contains, "ExecutionDriver")
    52  	c.Assert(out, checker.Contains, "not supported")
    53  }