MCPcopy Index your code
hub / github.com/docker/docker-agent / TestShouldRetryWithCredentials

Function TestShouldRetryWithCredentials

pkg/remote/pull_test.go:39–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func 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

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected