Skip to content

Commit

Permalink
conformance: check response status before checking location
Browse files Browse the repository at this point in the history
I noticed that when these tests are running against a server
that returns the wrong status code (an error, for example),
the failure that we see doesn't mention the status code, but
only that the returned location is empty.

This change checks the status code first, as if that's wrong, the
location is very unlikely to be relevant.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
  • Loading branch information
rogpeppe committed May 25, 2023
1 parent 7fcdf80 commit a971875
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conformance/02_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ var test02Push = func() {
resp, err := client.Do(req)
Expect(err).To(BeNil())
location := resp.Header().Get("Location")
Expect(location).ToNot(BeEmpty())
Expect(resp.StatusCode()).To(Equal(http.StatusAccepted))
Expect(location).ToNot(BeEmpty())
lastResponse = resp
})

Expand All @@ -246,9 +246,9 @@ var test02Push = func() {
SetQueryParam("digest", testBlobBDigest)
resp, err := client.Do(req)
Expect(err).To(BeNil())
Expect(resp.StatusCode()).To(Equal(http.StatusCreated))
location := resp.Header().Get("Location")
Expect(location).ToNot(BeEmpty())
Expect(resp.StatusCode()).To(Equal(http.StatusCreated))
})
})

Expand Down

0 comments on commit a971875

Please sign in to comment.