docker_cli_version_test.go 797 B

1234567891011121314151617181920212223242526272829303132333435
  1. package main
  2. import (
  3. "os/exec"
  4. "strings"
  5. "testing"
  6. )
  7. // ensure docker version works
  8. func TestVersionEnsureSucceeds(t *testing.T) {
  9. versionCmd := exec.Command(dockerBinary, "version")
  10. out, _, err := runCommandWithOutput(versionCmd)
  11. if err != nil {
  12. t.Fatalf("failed to execute docker version: %s, %v", out, err)
  13. }
  14. stringsToCheck := []string{
  15. "Client version:",
  16. "Client API version:",
  17. "Go version (client):",
  18. "Git commit (client):",
  19. "Server version:",
  20. "Server API version:",
  21. "Go version (server):",
  22. "Git commit (server):",
  23. }
  24. for _, linePrefix := range stringsToCheck {
  25. if !strings.Contains(out, linePrefix) {
  26. t.Errorf("couldn't find string %v in output", linePrefix)
  27. }
  28. }
  29. logDone("version - verify that it works and that the output is properly formatted")
  30. }