(t *testing.T)
| 37 | } |
| 38 | |
| 39 | func TestShouldRetryWithCredentials(t *testing.T) { |
| 40 | t.Parallel() |
| 41 | |
| 42 | tests := []struct { |
| 43 | name string |
| 44 | err error |
| 45 | expected bool |
| 46 | }{ |
| 47 | {"nil error", nil, false}, |
| 48 | {"generic error", errors.New("boom"), false}, |
| 49 | {"unauthorized", &transport.Error{StatusCode: http.StatusUnauthorized}, true}, |
| 50 | {"forbidden", &transport.Error{StatusCode: http.StatusForbidden}, true}, |
| 51 | {"too many requests", &transport.Error{StatusCode: http.StatusTooManyRequests}, true}, |
| 52 | {"not found", &transport.Error{StatusCode: http.StatusNotFound}, false}, |
| 53 | {"server error", &transport.Error{StatusCode: http.StatusInternalServerError}, false}, |
| 54 | } |
| 55 | |
| 56 | for _, tt := range tests { |
| 57 | t.Run(tt.name, func(t *testing.T) { |
| 58 | t.Parallel() |
| 59 | assert.Equal(t, tt.expected, shouldRetryWithCredentials(tt.err)) |
| 60 | }) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // testRegistry is a minimal in-memory OCI registry for exercising session |
| 65 | // behavior. It serves one image's manifest and layers and can be configured to |
nothing calls this directly
no test coverage detected