github.com/nguyentm83/docker@v1.5.0/integration-cli/docker_cli_version_test.go (about)

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