f4942ed8 |
package main
import (
"net/http" |
b4988d8d |
|
0fd5a654 |
"fmt"
"github.com/docker/docker/client" |
33968e6c |
"github.com/docker/docker/integration-cli/checker" |
d69d4799 |
"github.com/docker/docker/integration-cli/request" |
b4988d8d |
"github.com/go-check/check" |
0fd5a654 |
"golang.org/x/net/context" |
f4942ed8 |
)
|
7fb7a477 |
func (s *DockerSuite) TestInfoAPI(c *check.C) { |
0fd5a654 |
cli, err := client.NewEnvClient()
c.Assert(err, checker.IsNil)
defer cli.Close() |
f4942ed8 |
|
0fd5a654 |
info, err := cli.Info(context.Background()) |
5cfa13ae |
c.Assert(err, checker.IsNil) |
f4942ed8 |
// always shown fields
stringsToCheck := []string{
"ID",
"Containers", |
e732f4e6 |
"ContainersRunning",
"ContainersPaused",
"ContainersStopped", |
f4942ed8 |
"Images",
"LoggingDriver",
"OperatingSystem",
"NCPU", |
4e8fcd40 |
"OSType",
"Architecture", |
f4942ed8 |
"MemTotal",
"KernelVersion", |
7cf343d1 |
"Driver", |
190654aa |
"ServerVersion",
"SecurityOptions"} |
f4942ed8 |
|
0fd5a654 |
out := fmt.Sprintf("%+v", info) |
f4942ed8 |
for _, linePrefix := range stringsToCheck { |
5cfa13ae |
c.Assert(out, checker.Contains, linePrefix) |
f4942ed8 |
}
} |
63b5a372 |
func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) { |
f811d5b1 |
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later |
63b5a372 |
|
0fd5a654 |
res, body, err := request.Get("/v1.20/info")
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
c.Assert(err, checker.IsNil)
b, err := request.ReadBody(body) |
63b5a372 |
c.Assert(err, checker.IsNil)
|
0fd5a654 |
out := string(b) |
63b5a372 |
c.Assert(out, checker.Contains, "ExecutionDriver")
c.Assert(out, checker.Contains, "not supported")
} |