A file can be removed between the validation that accepted it and the upload that opens it, which is the only way a resolved asset reaches the endpoint with nothing behind it.
(t *testing.T)
| 350 | // that opens it, which is the only way a resolved asset reaches the endpoint |
| 351 | // with nothing behind it. |
| 352 | func TestUploadMissingFile(t *testing.T) { |
| 353 | a := testAsset(t, "gone.png", "image/png", "the bytes") |
| 354 | openFile = func(path string) (io.ReadCloser, error) { |
| 355 | return nil, &fs.PathError{Op: "open", Path: path, Err: fs.ErrNotExist} |
| 356 | } |
| 357 | |
| 358 | reg := &httpmock.Registry{} |
| 359 | defer reg.Verify(t) |
| 360 | |
| 361 | _, err := newTestUploader(t, reg, "github.com", 1).upload(context.Background(), a) |
| 362 | |
| 363 | require.Error(t, err) |
| 364 | assert.Contains(t, err.Error(), "failed to upload ./gone.png: ") |
| 365 | assert.Empty(t, reg.Requests) |
| 366 | } |
| 367 | |
| 368 | func TestNewUploader(t *testing.T) { |
| 369 | const badTokenErr = "unsupported authentication type" |