From 315c7e025fc761d76815df4674bbb7d166b77a27 Mon Sep 17 00:00:00 2001 From: Brad Moylan Date: Thu, 13 Oct 2022 16:16:58 -0700 Subject: [PATCH] conformance.test01Pull: Check client errors before using response object Previously, if the client.Do returned an (ignored) error and nil response, the subsequent usages of `resp` panic. Signed-off-by: Brad Moylan --- conformance/01_pull_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/conformance/01_pull_test.go b/conformance/01_pull_test.go index 220a35bc..2954894d 100644 --- a/conformance/01_pull_test.go +++ b/conformance/01_pull_test.go @@ -19,13 +19,14 @@ var test01Pull = func() { SkipIfDisabled(pull) RunOnlyIf(runPullSetup) req := client.NewRequest(reggie.POST, "/v2//blobs/uploads/") - resp, _ := client.Do(req) + resp, err := client.Do(req) + Expect(err).To(BeNil()) req = client.NewRequest(reggie.PUT, resp.GetRelativeLocation()). SetQueryParam("digest", configs[0].Digest). SetHeader("Content-Type", "application/octet-stream"). SetHeader("Content-Length", configs[0].ContentLength). SetBody(configs[0].Content) - resp, err := client.Do(req) + resp, err = client.Do(req) Expect(err).To(BeNil()) Expect(resp.StatusCode()).To(SatisfyAll( BeNumerically(">=", 200), @@ -36,13 +37,14 @@ var test01Pull = func() { SkipIfDisabled(pull) RunOnlyIf(runPullSetup) req := client.NewRequest(reggie.POST, "/v2//blobs/uploads/") - resp, _ := client.Do(req) + resp, err := client.Do(req) + Expect(err).To(BeNil()) req = client.NewRequest(reggie.PUT, resp.GetRelativeLocation()). SetQueryParam("digest", layerBlobDigest). SetHeader("Content-Type", "application/octet-stream"). SetHeader("Content-Length", layerBlobContentLength). SetBody(layerBlobData) - resp, err := client.Do(req) + resp, err = client.Do(req) Expect(err).To(BeNil()) Expect(resp.StatusCode()).To(SatisfyAll( BeNumerically(">=", 200), @@ -68,7 +70,8 @@ var test01Pull = func() { SkipIfDisabled(pull) RunOnlyIf(runPullSetup) req := client.NewRequest(reggie.GET, "/v2//tags/list") - resp, _ := client.Do(req) + resp, err := client.Do(req) + Expect(err).To(BeNil()) tag = getTagNameFromResponse(resp) // attempt to forcibly overwrite this tag with the unique manifest for this run