github.com/OpenFlowLabs/moby@v17.12.1-ce-rc2+incompatible/integration-cli/docker_api_info_test.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"fmt"
     7  
     8  	"github.com/docker/docker/client"
     9  	"github.com/docker/docker/integration-cli/checker"
    10  	"github.com/docker/docker/integration-cli/request"
    11  	"github.com/go-check/check"
    12  	"golang.org/x/net/context"
    13  )
    14  
    15  func (s *DockerSuite) TestInfoAPI(c *check.C) {
    16  	cli, err := client.NewEnvClient()
    17  	c.Assert(err, checker.IsNil)
    18  	defer cli.Close()
    19  
    20  	info, err := cli.Info(context.Background())
    21  	c.Assert(err, checker.IsNil)
    22  
    23  	// always shown fields
    24  	stringsToCheck := []string{
    25  		"ID",
    26  		"Containers",
    27  		"ContainersRunning",
    28  		"ContainersPaused",
    29  		"ContainersStopped",
    30  		"Images",
    31  		"LoggingDriver",
    32  		"OperatingSystem",
    33  		"NCPU",
    34  		"OSType",
    35  		"Architecture",
    36  		"MemTotal",
    37  		"KernelVersion",
    38  		"Driver",
    39  		"ServerVersion",
    40  		"SecurityOptions"}
    41  
    42  	out := fmt.Sprintf("%+v", info)
    43  	for _, linePrefix := range stringsToCheck {
    44  		c.Assert(out, checker.Contains, linePrefix)
    45  	}
    46  }
    47  
    48  func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) {
    49  	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
    50  
    51  	res, body, err := request.Get("/v1.20/info")
    52  	c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
    53  	c.Assert(err, checker.IsNil)
    54  
    55  	b, err := request.ReadBody(body)
    56  	c.Assert(err, checker.IsNil)
    57  
    58  	out := string(b)
    59  	c.Assert(out, checker.Contains, "ExecutionDriver")
    60  	c.Assert(out, checker.Contains, "not supported")
    61  }