Skip to content

Commit 68d9bee

Browse files
committed
Migrates docker info tests to integration api tests
This fix migrates docker info tests in integration-cli to integration tests. Signed-off-by: Yong Tang <[email protected]>
1 parent 2e8ccbb commit 68d9bee

3 files changed

Lines changed: 60 additions & 62 deletions

File tree

integration-cli/docker_api_info_test.go

Lines changed: 0 additions & 61 deletions
This file was deleted.

integration/system/info_linux_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
package system
44

55
import (
6+
"net/http"
67
"testing"
78

9+
req "github.com/docker/docker/integration-cli/request"
810
"github.com/docker/docker/integration/util/request"
911
"github.com/stretchr/testify/assert"
1012
"github.com/stretchr/testify/require"
1113
"golang.org/x/net/context"
1214
)
1315

14-
func TestInfo_BinaryCommits(t *testing.T) {
16+
func TestInfoBinaryCommits(t *testing.T) {
1517
client := request.NewAPIClient(t)
1618

1719
info, err := client.Info(context.Background())
@@ -32,3 +34,18 @@ func TestInfo_BinaryCommits(t *testing.T) {
3234
assert.Equal(t, testEnv.DaemonInfo.RuncCommit.Expected, info.RuncCommit.Expected)
3335
assert.Equal(t, info.RuncCommit.Expected, info.RuncCommit.ID)
3436
}
37+
38+
func TestInfoAPIVersioned(t *testing.T) {
39+
// Windows only supports 1.25 or later
40+
41+
res, body, err := req.Get("/v1.20/info")
42+
require.NoError(t, err)
43+
assert.Equal(t, res.StatusCode, http.StatusOK)
44+
45+
b, err := req.ReadBody(body)
46+
require.NoError(t, err)
47+
48+
out := string(b)
49+
assert.Contains(t, out, "ExecutionDriver")
50+
assert.Contains(t, out, "not supported")
51+
}

integration/system/info_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package system
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/docker/docker/integration/util/request"
8+
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
10+
"golang.org/x/net/context"
11+
)
12+
13+
func TestInfoAPI(t *testing.T) {
14+
client := request.NewAPIClient(t)
15+
16+
info, err := client.Info(context.Background())
17+
require.NoError(t, err)
18+
19+
// always shown fields
20+
stringsToCheck := []string{
21+
"ID",
22+
"Containers",
23+
"ContainersRunning",
24+
"ContainersPaused",
25+
"ContainersStopped",
26+
"Images",
27+
"LoggingDriver",
28+
"OperatingSystem",
29+
"NCPU",
30+
"OSType",
31+
"Architecture",
32+
"MemTotal",
33+
"KernelVersion",
34+
"Driver",
35+
"ServerVersion",
36+
"SecurityOptions"}
37+
38+
out := fmt.Sprintf("%+v", info)
39+
for _, linePrefix := range stringsToCheck {
40+
assert.Contains(t, out, linePrefix)
41+
}
42+
}

0 commit comments

Comments
 (0)