MCPcopy Index your code
hub / github.com/containerd/containerd / TestPusherHTTPFallback

Function TestPusherHTTPFallback

core/remotes/docker/pusher_test.go:128–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestPusherHTTPFallback(t *testing.T) {
129 ctx := logtest.WithT(context.Background(), t)
130
131 p, reg, _, done := samplePusher(t)
132 defer done()
133
134 reg.uploadable = true
135 reg.username = "testuser"
136 reg.secret = "testsecret"
137 reg.locationPrefix = p.hosts[0].Scheme + "://" + p.hosts[0].Host
138
139 p.hosts[0].Scheme = "https"
140 client := p.hosts[0].Client
141 if client == nil {
142 clientC := *http.DefaultClient
143 client = &clientC
144 }
145 if client.Transport == nil {
146 client.Transport = http.DefaultTransport
147 }
148 client.Transport = NewHTTPFallback(client.Transport)
149 p.hosts[0].Client = client
150 phost := p.hosts[0].Host
151 p.hosts[0].Authorizer = NewDockerAuthorizer(WithAuthCreds(func(host string) (string, string, error) {
152 if host == phost {
153 return "testuser", "testsecret", nil
154 }
155 return "", "", nil
156 }))
157
158 layerContent := []byte("test")
159 if err := tryUpload(ctx, t, p, layerContent); err != nil {
160 t.Errorf("upload failed: %v", err)
161 }
162}
163
164// TestPusherErrReset tests the push method if the request needs to be retried
165// i.e when ErrReset occurs

Callers

nothing calls this directly

Calls 5

samplePusherFunction · 0.85
NewHTTPFallbackFunction · 0.85
NewDockerAuthorizerFunction · 0.85
WithAuthCredsFunction · 0.85
tryUploadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…