1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/docker_cli_version_test.go
John Howard 7c74809fe9 Align output of docker version again
Signed-off-by: John Howard <jhoward@microsoft.com>
(cherry picked from commit dfeaf7a959)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
2016-11-29 14:07:39 -08:00

58 lines
1.6 KiB
Go

package main
import (
"strings"
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
)
// ensure docker version works
func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) {
out, _ := dockerCmd(c, "version")
stringsToCheck := map[string]int{
"Client:": 1,
"Server:": 1,
" Version:": 2,
" API version:": 2,
" Go version:": 2,
" Git commit:": 2,
" OS/Arch:": 2,
" Built:": 2,
}
for k, v := range stringsToCheck {
c.Assert(strings.Count(out, k), checker.Equals, v, check.Commentf("The count of %v in %s does not match excepted", k, out))
}
}
// 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)
testVersionPlatform(c, "linux")
}
func testVersionPlatform(c *check.C, platform string) {
out, _ := dockerCmd(c, "version")
expected := "OS/Arch: " + platform
split := strings.Split(out, "\n")
c.Assert(len(split) >= 14, checker.Equals, true, check.Commentf("got %d lines from version", len(split)))
// 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
}
}
c.Assert(bFound, checker.Equals, true, check.Commentf("Could not find server '%s' in '%s'", expected, out))
}