From a971875827e86d32dc24245b139bb673392c94f2 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Thu, 25 May 2023 17:46:42 +0100 Subject: [PATCH] conformance: check response status before checking location 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 --- conformance/02_push_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conformance/02_push_test.go b/conformance/02_push_test.go index 5c4122a9..94b53bcf 100644 --- a/conformance/02_push_test.go +++ b/conformance/02_push_test.go @@ -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 }) @@ -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)) }) })