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