MCPcopy
hub / github.com/rclone/rclone / TestDirRemove

Function TestDirRemove

vfs/dir_test.go:437–474  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

435}
436
437func TestDirRemove(t *testing.T) {
438 r, vfs, dir, _ := dirCreate(t)
439
440 // check directory is there
441 node, err := vfs.Stat("dir")
442 require.NoError(t, err)
443 assert.True(t, node.IsDir())
444
445 err = dir.Remove()
446 assert.Equal(t, ENOTEMPTY, err)
447
448 // Delete the sub file
449 node, err = vfs.Stat("dir/file1")
450 require.NoError(t, err)
451 err = node.Remove()
452 require.NoError(t, err)
453
454 // Remove the now empty directory
455 err = dir.Remove()
456 require.NoError(t, err)
457
458 // check directory is not there
459 _, err = vfs.Stat("dir")
460 assert.Equal(t, ENOENT, err)
461
462 // check the vfs
463 root, err := vfs.Root()
464 require.NoError(t, err)
465 checkListing(t, root, []string(nil))
466
467 // check the underlying r.Fremote
468 fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{}, []string{}, r.Fremote.Precision())
469
470 // read only check
471 vfs.Opt.ReadOnly = true
472 err = dir.Remove()
473 assert.Equal(t, EROFS, err)
474}
475
476func TestDirRemoveAll(t *testing.T) {
477 r, vfs, dir, _ := dirCreate(t)

Callers

nothing calls this directly

Calls 9

dirCreateFunction · 0.85
checkListingFunction · 0.70
StatMethod · 0.65
RemoveMethod · 0.65
RootMethod · 0.65
PrecisionMethod · 0.65
IsDirMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…