TestBuildUserNamespaceValidateCapabilitiesAreV2: verify build completed
Check if the `docker build` completed successfully before continuing.
@@ -12,6 +12,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/container"
+ "github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/testutil/daemon"
"github.com/docker/docker/testutil/fakecontext"
@@ -66,17 +67,10 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
})
assert.NilError(t, err)
defer resp.Body.Close()
- buf := make([]byte, 1024)
- for {
- n, err := resp.Body.Read(buf)
- if err != nil && err != io.EOF {
- t.Fatalf("Error reading ImageBuild response: %v", err)
- break
- }
- if n == 0 {
- break
- }
- }
+
+ buf := bytes.NewBuffer(nil)
+ err = jsonmessage.DisplayJSONMessagesStream(resp.Body, buf, 0, false, nil)
+ assert.NilError(t, err)
reader, err := clientUserRemap.ImageSave(ctx, []string{imageTag})
assert.NilError(t, err, "failed to download capabilities image")
@@ -106,16 +100,9 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
loadResp, err := clientNoUserRemap.ImageLoad(ctx, tarReader, false)
assert.NilError(t, err, "failed to load image tar file")
defer loadResp.Body.Close()
- for {
- n, err := loadResp.Body.Read(buf)
- if err != nil && err != io.EOF {
- t.Fatalf("Error reading ImageLoad response: %v", err)
- break
- }
- if n == 0 {
- break
- }
- }
+ buf = bytes.NewBuffer(nil)
+ err = jsonmessage.DisplayJSONMessagesStream(loadResp.Body, buf, 0, false, nil)
+ assert.NilError(t, err)
cid := container.Run(ctx, t, clientNoUserRemap,
container.WithImage(imageTag),
