docker_cli_version_test.go 858 B

1234567891011121314151617181920212223242526272829
  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{"Client version:", "Go version (client):", "Git commit (client):", "Server version:", "Git commit (server):", "Go version (server):", "Last stable version:"}
  17. for _, linePrefix := range stringsToCheck {
  18. if !strings.Contains(out, linePrefix) {
  19. t.Errorf("couldn't find string %v in output", linePrefix)
  20. }
  21. }
  22. logDone("version - verify that it works and that the output is properly formatted")
  23. }