From 0ffdacae00b4daf2bc546cfabb4d3583dae23dd1 Mon Sep 17 00:00:00 2001 From: Caleb Woodbine Date: Thu, 31 Mar 2022 10:33:28 +1300 Subject: [PATCH] Add name to scenario --- cmd/archeio/main_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/archeio/main_test.go b/cmd/archeio/main_test.go index ae10d43..0dfaeb1 100644 --- a/cmd/archeio/main_test.go +++ b/cmd/archeio/main_test.go @@ -22,6 +22,7 @@ type expected struct { } type scenario struct { + name string request request expected expected } @@ -34,6 +35,7 @@ type suite struct { func (s *suite) runTestSuite(t *testing.T) { for _, sc := range s.scenarios { + t.Logf("Running scenario '%v'\n", sc.name) server := httptest.NewServer(s.handler) defer server.Close() client := server.Client() @@ -75,24 +77,29 @@ func TestMakeHandler(t *testing.T) { handler: makeHandler(defaultUpstreamRegistry), scenarios: []scenario{ { + name: "root is not found", request: request{path: "/", redirect: false}, expected: expected{path: "/", statusCode: http.StatusNotFound}, }, // when not redirecting { + name: "/v2/ returns 308 without following redirect", request: request{path: "/v2/", redirect: false}, expected: expected{url: defaultUpstreamRegistry + "/v2/", statusCode: http.StatusPermanentRedirect}, }, { + name: "/v1/ returns 308 without following redirect", request: request{path: "/v1/", redirect: false}, expected: expected{url: defaultUpstreamRegistry + "/v1/", statusCode: http.StatusPermanentRedirect}, }, // when redirecting, results from k8s.gcr.io { + name: "/v2/ returns 401 from gcr, with following redirect", request: request{path: "/v2/", redirect: true}, expected: expected{url: defaultUpstreamRegistry + "/v2/", statusCode: http.StatusUnauthorized}, }, { + name: "/v1/ returns 404 from gcr, with following redirect", request: request{path: "/v1/", redirect: true}, expected: expected{url: defaultUpstreamRegistry + "/v1/", statusCode: http.StatusNotFound}, }, @@ -109,6 +116,7 @@ func TestDoV2(t *testing.T) { }), scenarios: []scenario{ { + name: "v2 handler returns 308 without following redirect", request: request{path: "/v2/", redirect: false}, expected: expected{url: defaultUpstreamRegistry + "/v2/", statusCode: http.StatusPermanentRedirect}, }, @@ -125,6 +133,7 @@ func TestDoV1(t *testing.T) { }), scenarios: []scenario{ { + name: "v1 handler returns 308 without following redirect", request: request{path: "/v1/", redirect: false}, expected: expected{url: defaultUpstreamRegistry + "/v1/", statusCode: http.StatusPermanentRedirect}, },