docker_api_info_test.go 1.2 KB

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