(t *testing.T)
| 489 | } |
| 490 | |
| 491 | func (f *Fs) InternalTestCleanupUnfinished(t *testing.T) { |
| 492 | ctx := context.Background() |
| 493 | |
| 494 | // B2CleanupHidden tests cleaning up hidden files |
| 495 | t.Run("CleanupUnfinished", func(t *testing.T) { |
| 496 | dirName := "unfinished" |
| 497 | fileCount := 5 |
| 498 | expectedFiles := []string{} |
| 499 | for i := 1; i < fileCount; i++ { |
| 500 | fileName := fmt.Sprintf("%s/unfinished-%d", dirName, i) |
| 501 | expectedFiles = append(expectedFiles, fileName) |
| 502 | obj := &Object{ |
| 503 | fs: f, |
| 504 | remote: fileName, |
| 505 | } |
| 506 | objInfo := object.NewStaticObjectInfo(fileName, fstest.Time("2002-02-03T04:05:06.499999999Z"), -1, true, nil, nil) |
| 507 | _, err := f.newLargeUpload(ctx, obj, nil, objInfo, f.opt.ChunkSize, false, nil) |
| 508 | require.NoError(t, err) |
| 509 | } |
| 510 | checkListing(ctx, t, f, dirName, expectedFiles) |
| 511 | |
| 512 | t.Run("DryRun", func(t *testing.T) { |
| 513 | // Listing should not change after dry run |
| 514 | ctx, ci := fs.AddConfig(ctx) |
| 515 | ci.DryRun = true |
| 516 | require.NoError(t, f.cleanUp(ctx, false, true, 0)) |
| 517 | checkListing(ctx, t, f, dirName, expectedFiles) |
| 518 | }) |
| 519 | |
| 520 | t.Run("RealThing", func(t *testing.T) { |
| 521 | // Listing should be empty after real cleanup |
| 522 | require.NoError(t, f.cleanUp(ctx, false, true, 0)) |
| 523 | checkListing(ctx, t, f, dirName, []string{}) |
| 524 | }) |
| 525 | }) |
| 526 | } |
| 527 | |
| 528 | func listAllFiles(ctx context.Context, t *testing.T, f *Fs, dirName string) []string { |
| 529 | bucket, directory := f.split(dirName) |
nothing calls this directly
no test coverage detected