github.com/darciopacifico/docker@v1.9.0-rc1/integration-cli/docker_cli_version_test.go (about) 1 package main 2 3 import ( 4 "strings" 5 6 "github.com/go-check/check" 7 ) 8 9 // ensure docker version works 10 func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) { 11 out, _ := dockerCmd(c, "version") 12 stringsToCheck := map[string]int{ 13 "Client:": 1, 14 "Server:": 1, 15 " Version:": 2, 16 " API version:": 2, 17 " Go version:": 2, 18 " Git commit:": 2, 19 " OS/Arch:": 2, 20 " Built:": 2, 21 } 22 23 for k, v := range stringsToCheck { 24 if strings.Count(out, k) != v { 25 c.Errorf("%v expected %d instances found %d", k, v, strings.Count(out, k)) 26 } 27 } 28 } 29 30 // ensure the Windows daemon return the correct platform string 31 func (s *DockerSuite) TestVersionPlatform_w(c *check.C) { 32 testRequires(c, DaemonIsWindows) 33 testVersionPlatform(c, "windows/amd64") 34 } 35 36 // ensure the Linux daemon return the correct platform string 37 func (s *DockerSuite) TestVersionPlatform_l(c *check.C) { 38 testRequires(c, DaemonIsLinux) 39 testVersionPlatform(c, "linux/amd64") 40 } 41 42 func testVersionPlatform(c *check.C, platform string) { 43 out, _ := dockerCmd(c, "version") 44 expected := "OS/Arch: " + platform 45 46 split := strings.Split(out, "\n") 47 if len(split) < 14 { // To avoid invalid indexing in loop below 48 c.Errorf("got %d lines from version", len(split)) 49 } 50 51 // Verify the second 'OS/Arch' matches the platform. Experimental has 52 // more lines of output than 'regular' 53 bFound := false 54 for i := 14; i < len(split); i++ { 55 if strings.Contains(split[i], expected) { 56 bFound = true 57 break 58 } 59 } 60 if !bFound { 61 c.Errorf("Could not find server '%s' in '%s'", expected, out) 62 } 63 }