docker_cli_info_test.go 698 B

1234567891011121314151617181920212223242526272829
  1. package main
  2. import (
  3. "fmt"
  4. "os/exec"
  5. "strings"
  6. "testing"
  7. )
  8. // ensure docker info succeeds
  9. func TestInfoEnsureSucceeds(t *testing.T) {
  10. versionCmd := exec.Command(dockerBinary, "info")
  11. out, exitCode, err := runCommandWithOutput(versionCmd)
  12. errorOut(err, t, fmt.Sprintf("encountered error while running docker info: %v", err))
  13. if err != nil || exitCode != 0 {
  14. t.Fatal("failed to execute docker info")
  15. }
  16. stringsToCheck := []string{"Containers:", "Execution Driver:", "Kernel 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("info - verify that it works")
  23. }