docker_cli_version_test.go 900 B

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