From a1eadff7ed9d13ae92aadcb13c743b95114ef9e1 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Wed, 21 Jun 2023 18:39:13 +0100 Subject: [PATCH] conformance: check response status before checking location (#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 --- 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)) }) })