Replace old version tests
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
5c10698d5c
commit
813d2e082a
5 changed files with 52 additions and 105 deletions
|
@ -1,18 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/dockerversion"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/go-check/check"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestGetVersion(c *check.C) {
|
||||
cli, err := client.NewEnvClient()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
v, err := cli.ServerVersion(context.Background())
|
||||
c.Assert(v.Version, checker.Equals, dockerversion.Version, check.Commentf("Version mismatch"))
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestExperimentalVersionTrue(c *check.C) {
|
||||
testExperimentalInVersion(c, ExperimentalDaemon, "*true")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestExperimentalVersionFalse(c *check.C) {
|
||||
testExperimentalInVersion(c, NotExperimentalDaemon, "*false")
|
||||
}
|
||||
|
||||
func testExperimentalInVersion(c *check.C, requirement func() bool, expectedValue string) {
|
||||
testRequires(c, requirement)
|
||||
out, _ := dockerCmd(c, "version")
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
if strings.HasPrefix(strings.TrimSpace(line), "Experimental:") {
|
||||
c.Assert(line, checker.Matches, expectedValue)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.Fatal(`"Experimental" not found in version output`)
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/integration-cli/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))
|
||||
}
|
28
integration/system/main_test.go
Normal file
28
integration/system/main_test.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/internal/test/environment"
|
||||
)
|
||||
|
||||
var testEnv *environment.Execution
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var err error
|
||||
testEnv, err = environment.New()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
testEnv.Print()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
func setupTest(t *testing.T) func() {
|
||||
environment.ProtectImages(t, testEnv)
|
||||
return func() { testEnv.Clean(t) }
|
||||
}
|
24
integration/system/version_test.go
Normal file
24
integration/system/version_test.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package system
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/integration-cli/request"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestVersion(t *testing.T) {
|
||||
client, err := request.NewClient()
|
||||
require.NoError(t, err)
|
||||
|
||||
version, err := client.ServerVersion(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotNil(t, version.APIVersion)
|
||||
assert.NotNil(t, version.Version)
|
||||
assert.NotNil(t, version.MinAPIVersion)
|
||||
assert.Equal(t, testEnv.DaemonInfo.ExperimentalBuild, version.Experimental)
|
||||
assert.Equal(t, testEnv.DaemonInfo.OSType, version.Os)
|
||||
}
|
Loading…
Reference in a new issue