Merge pull request #50521 from thaJeztah/move_StatsResponseReader

api/types/container.StatsResponseReader: move to client
This commit is contained in:
Sebastiaan van Stijn
2025-07-28 12:31:33 +02:00
committed by GitHub
8 changed files with 59 additions and 60 deletions

View File

@@ -110,10 +110,10 @@ func (s *DockerAPISuite) TestContainerAPIGetExport(c *testing.T) {
found := false
for tarReader := tar.NewReader(body); ; {
h, err := tarReader.Next()
if err != nil && err == io.EOF {
if errors.Is(err, io.EOF) {
break
}
if h.Name == "test" {
if h != nil && h.Name == "test" {
found = true
break
}
@@ -149,7 +149,7 @@ func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) {
runSleepingContainer(c, "--name", name)
type b struct {
stats container.StatsResponseReader
stats client.StatsResponseReader
err error
}
@@ -175,10 +175,11 @@ func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) {
c.Fatal("stream was not closed after container was removed")
case sr := <-bc:
dec := json.NewDecoder(sr.stats.Body)
defer sr.stats.Body.Close()
var s *container.StatsResponse
// decode only one object from the stream
assert.NilError(c, dec.Decode(&s))
err := dec.Decode(&s)
_ = sr.stats.Body.Close()
assert.NilError(c, err)
}
}
@@ -253,7 +254,7 @@ func (s *DockerAPISuite) TestGetContainerStatsStream(c *testing.T) {
runSleepingContainer(c, "--name", name)
type b struct {
stats container.StatsResponseReader
stats client.StatsResponseReader
err error
}
@@ -294,7 +295,7 @@ func (s *DockerAPISuite) TestGetContainerStatsNoStream(c *testing.T) {
runSleepingContainer(c, "--name", name)
type b struct {
stats container.StatsResponseReader
stats client.StatsResponseReader
err error
}
@@ -1229,7 +1230,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T)
cli.WaitRun(c, name)
type b struct {
stats container.StatsResponseReader
stats client.StatsResponseReader
err error
}
bc := make(chan b, 1)