Browse code

Merge pull request #36235 from yongtang/02072018-info-api-test

Migrates docker info tests to integration api tests

Daniel Nephin authored on 2018/02/09 02:55:08
Showing 3 changed files
1 1
deleted file mode 100644
... ...
@@ -1,61 +0,0 @@
1
-package main
2
-
3
-import (
4
-	"net/http"
5
-
6
-	"fmt"
7
-
8
-	"github.com/docker/docker/client"
9
-	"github.com/docker/docker/integration-cli/checker"
10
-	"github.com/docker/docker/integration-cli/request"
11
-	"github.com/go-check/check"
12
-	"golang.org/x/net/context"
13
-)
14
-
15
-func (s *DockerSuite) TestInfoAPI(c *check.C) {
16
-	cli, err := client.NewEnvClient()
17
-	c.Assert(err, checker.IsNil)
18
-	defer cli.Close()
19
-
20
-	info, err := cli.Info(context.Background())
21
-	c.Assert(err, checker.IsNil)
22
-
23
-	// always shown fields
24
-	stringsToCheck := []string{
25
-		"ID",
26
-		"Containers",
27
-		"ContainersRunning",
28
-		"ContainersPaused",
29
-		"ContainersStopped",
30
-		"Images",
31
-		"LoggingDriver",
32
-		"OperatingSystem",
33
-		"NCPU",
34
-		"OSType",
35
-		"Architecture",
36
-		"MemTotal",
37
-		"KernelVersion",
38
-		"Driver",
39
-		"ServerVersion",
40
-		"SecurityOptions"}
41
-
42
-	out := fmt.Sprintf("%+v", info)
43
-	for _, linePrefix := range stringsToCheck {
44
-		c.Assert(out, checker.Contains, linePrefix)
45
-	}
46
-}
47
-
48
-func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) {
49
-	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
50
-
51
-	res, body, err := request.Get("/v1.20/info")
52
-	c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
53
-	c.Assert(err, checker.IsNil)
54
-
55
-	b, err := request.ReadBody(body)
56
-	c.Assert(err, checker.IsNil)
57
-
58
-	out := string(b)
59
-	c.Assert(out, checker.Contains, "ExecutionDriver")
60
-	c.Assert(out, checker.Contains, "not supported")
61
-}
... ...
@@ -3,15 +3,17 @@
3 3
 package system // import "github.com/docker/docker/integration/system"
4 4
 
5 5
 import (
6
+	"net/http"
6 7
 	"testing"
7 8
 
9
+	req "github.com/docker/docker/integration-cli/request"
8 10
 	"github.com/docker/docker/integration/util/request"
9 11
 	"github.com/stretchr/testify/assert"
10 12
 	"github.com/stretchr/testify/require"
11 13
 	"golang.org/x/net/context"
12 14
 )
13 15
 
14
-func TestInfo_BinaryCommits(t *testing.T) {
16
+func TestInfoBinaryCommits(t *testing.T) {
15 17
 	client := request.NewAPIClient(t)
16 18
 
17 19
 	info, err := client.Info(context.Background())
... ...
@@ -32,3 +34,18 @@ func TestInfo_BinaryCommits(t *testing.T) {
32 32
 	assert.Equal(t, testEnv.DaemonInfo.RuncCommit.Expected, info.RuncCommit.Expected)
33 33
 	assert.Equal(t, info.RuncCommit.Expected, info.RuncCommit.ID)
34 34
 }
35
+
36
+func TestInfoAPIVersioned(t *testing.T) {
37
+	// Windows only supports 1.25 or later
38
+
39
+	res, body, err := req.Get("/v1.20/info")
40
+	require.NoError(t, err)
41
+	assert.Equal(t, res.StatusCode, http.StatusOK)
42
+
43
+	b, err := req.ReadBody(body)
44
+	require.NoError(t, err)
45
+
46
+	out := string(b)
47
+	assert.Contains(t, out, "ExecutionDriver")
48
+	assert.Contains(t, out, "not supported")
49
+}
35 50
new file mode 100644
... ...
@@ -0,0 +1,42 @@
0
+package system
1
+
2
+import (
3
+	"fmt"
4
+	"testing"
5
+
6
+	"github.com/docker/docker/integration/util/request"
7
+	"github.com/stretchr/testify/assert"
8
+	"github.com/stretchr/testify/require"
9
+	"golang.org/x/net/context"
10
+)
11
+
12
+func TestInfoAPI(t *testing.T) {
13
+	client := request.NewAPIClient(t)
14
+
15
+	info, err := client.Info(context.Background())
16
+	require.NoError(t, err)
17
+
18
+	// always shown fields
19
+	stringsToCheck := []string{
20
+		"ID",
21
+		"Containers",
22
+		"ContainersRunning",
23
+		"ContainersPaused",
24
+		"ContainersStopped",
25
+		"Images",
26
+		"LoggingDriver",
27
+		"OperatingSystem",
28
+		"NCPU",
29
+		"OSType",
30
+		"Architecture",
31
+		"MemTotal",
32
+		"KernelVersion",
33
+		"Driver",
34
+		"ServerVersion",
35
+		"SecurityOptions"}
36
+
37
+	out := fmt.Sprintf("%+v", info)
38
+	for _, linePrefix := range stringsToCheck {
39
+		assert.Contains(t, out, linePrefix)
40
+	}
41
+}