Skip to content

Commit

Permalink
conformance: check response status before checking location (opencont…
Browse files Browse the repository at this point in the history
…ainers#420)

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 <[email protected]>
  • Loading branch information
rogpeppe authored and sudo-bmitch committed Aug 18, 2023
1 parent 9be5be1 commit f4352a1
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 f4352a1

Please sign in to comment.