MCPcopy
hub / github.com/rclone/rclone / InternalTestCleanupUnfinished

Method InternalTestCleanupUnfinished

backend/b2/b2_internal_test.go:491–526  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

489}
490
491func (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
528func listAllFiles(ctx context.Context, t *testing.T, f *Fs, dirName string) []string {
529 bucket, directory := f.split(dirName)

Callers

nothing calls this directly

Calls 7

newLargeUploadMethod · 0.95
cleanUpMethod · 0.95
NewStaticObjectInfoFunction · 0.92
TimeFunction · 0.92
AddConfigFunction · 0.92
checkListingFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected