integration-cli/docker_cli_version_test.go
6db32fde
 package main
 
 import (
 	"strings"
dc944ea7
 
d4d0718e
 	"github.com/docker/docker/pkg/integration/checker"
dc944ea7
 	"github.com/go-check/check"
6db32fde
 )
 
 // ensure docker version works
dc944ea7
 func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) {
eef6eda7
 	out, _ := dockerCmd(c, "version")
87eae0d6
 	stringsToCheck := map[string]int{
 		"Client:":       1,
 		"Server:":       1,
 		" Version:":     2,
 		" API version:": 2,
 		" Go version:":  2,
 		" Git commit:":  2,
 		" OS/Arch:":     2,
 		" Built:":       2,
b246fc33
 	}
6db32fde
 
87eae0d6
 	for k, v := range stringsToCheck {
d4d0718e
 		c.Assert(strings.Count(out, k), checker.Equals, v, check.Commentf("The count of %v in %s does not match excepted", k, out))
6db32fde
 	}
 }
cd18e7bb
 
 // ensure the Windows daemon return the correct platform string
 func (s *DockerSuite) TestVersionPlatform_w(c *check.C) {
 	testRequires(c, DaemonIsWindows)
 	testVersionPlatform(c, "windows/amd64")
 }
 
 // ensure the Linux daemon return the correct platform string
 func (s *DockerSuite) TestVersionPlatform_l(c *check.C) {
 	testRequires(c, DaemonIsLinux)
b1cc78b8
 	testVersionPlatform(c, "linux")
cd18e7bb
 }
 
 func testVersionPlatform(c *check.C, platform string) {
 	out, _ := dockerCmd(c, "version")
 	expected := "OS/Arch:      " + platform
 
 	split := strings.Split(out, "\n")
d4d0718e
 	c.Assert(len(split) >= 14, checker.Equals, true, check.Commentf("got %d lines from version", len(split)))
cd18e7bb
 
 	// Verify the second 'OS/Arch' matches the platform. Experimental has
 	// more lines of output than 'regular'
 	bFound := false
 	for i := 14; i < len(split); i++ {
 		if strings.Contains(split[i], expected) {
 			bFound = true
 			break
 		}
 	}
d4d0718e
 	c.Assert(bFound, checker.Equals, true, check.Commentf("Could not find server '%s' in '%s'", expected, out))
cd18e7bb
 }