(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…