docker_api_info_test.go 1.2 KB

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