Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -1134,7 +1134,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) |
| 1134 | 1134 |
assert.NilError(c, err) |
| 1135 | 1135 |
defer apiClient.Close() |
| 1136 | 1136 |
|
| 1137 |
- _, err = apiClient.ContainerCreate(testutil.GetContext(c), client.ContainerCreateOptions{
|
|
| 1137 |
+ ctr, err := apiClient.ContainerCreate(testutil.GetContext(c), client.ContainerCreateOptions{
|
|
| 1138 | 1138 |
Config: &config, |
| 1139 | 1139 |
HostConfig: &container.HostConfig{},
|
| 1140 | 1140 |
NetworkingConfig: &network.NetworkingConfig{},
|
| ... | ... |
@@ -1142,9 +1142,9 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) |
| 1142 | 1142 |
}) |
| 1143 | 1143 |
assert.NilError(c, err) |
| 1144 | 1144 |
|
| 1145 |
- err = apiClient.ContainerStart(testutil.GetContext(c), name, client.ContainerStartOptions{})
|
|
| 1145 |
+ err = apiClient.ContainerStart(testutil.GetContext(c), ctr.ID, client.ContainerStartOptions{})
|
|
| 1146 | 1146 |
assert.NilError(c, err) |
| 1147 |
- cli.WaitRun(c, name) |
|
| 1147 |
+ cli.WaitRun(c, ctr.ID) |
|
| 1148 | 1148 |
|
| 1149 | 1149 |
type b struct {
|
| 1150 | 1150 |
stats client.StatsResponseReader |
| ... | ... |
@@ -1153,7 +1153,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) |
| 1153 | 1153 |
bc := make(chan b, 1) |
| 1154 | 1154 |
go func() {
|
| 1155 | 1155 |
stats, err := apiClient.ContainerStats(testutil.GetContext(c), name, false) |
| 1156 |
- bc <- b{stats, err}
|
|
| 1156 |
+ bc <- b{stats: stats, err: err}
|
|
| 1157 | 1157 |
}() |
| 1158 | 1158 |
|
| 1159 | 1159 |
// allow some time to stream the stats from the container |
| ... | ... |
@@ -1167,7 +1167,10 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) |
| 1167 | 1167 |
c.Fatal("stream was not closed after container was removed")
|
| 1168 | 1168 |
case sr := <-bc: |
| 1169 | 1169 |
assert.NilError(c, sr.err) |
| 1170 |
- sr.stats.Body.Close() |
|
| 1170 |
+ var v container.StatsResponse |
|
| 1171 |
+ assert.NilError(c, json.NewDecoder(sr.stats.Body).Decode(&v)) |
|
| 1172 |
+ assert.Check(c, is.Equal(v.ID, ctr.ID)) |
|
| 1173 |
+ _ = sr.stats.Body.Close() |
|
| 1171 | 1174 |
} |
| 1172 | 1175 |
} |
| 1173 | 1176 |
|