Skip to content

Commit

Permalink
conformance.test01Pull: Check client errors before using response object
Browse files Browse the repository at this point in the history
Previously, if the client.Do returned an (ignored) error and nil response, the subsequent usages of `resp` panic.

Signed-off-by: Brad Moylan <bmoylan@palantir.com>
  • Loading branch information
bmoylan committed Oct 13, 2022
1 parent b76b344 commit 315c7e0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions conformance/01_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ var test01Pull = func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.POST, "/v2/<name>/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),
Expand All @@ -36,13 +37,14 @@ var test01Pull = func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.POST, "/v2/<name>/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),
Expand All @@ -68,7 +70,8 @@ var test01Pull = func() {
SkipIfDisabled(pull)
RunOnlyIf(runPullSetup)
req := client.NewRequest(reggie.GET, "/v2/<name>/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
Expand Down

0 comments on commit 315c7e0

Please sign in to comment.