Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fstests: add backend integration test for purging root directory #7247

Nick Craig-Wood9c145628506d
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index 3d63290d8..f6ab79853 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -1156,6 +1156,48 @@ func Run(t *testing.T, opt *Opt) {
}, fs.GetModifyWindow(ctx, f))
})
+ // TestFsPurge tests Purge on the Root
+ t.Run("FsPurgeRoot", func(t *testing.T) {
+ skipIfNotOk(t)
+
+ // Check have Purge
+ doPurge := f.Features().Purge
+ if doPurge == nil {
+ t.Skip("FS has no Purge interface")
+ }
+
+ // put up a file to purge
+ fileToPurge := fstest.Item{
+ ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"),
+ Path: "dirToPurgeFromRoot/fileToPurgeFromRoot.txt",
+ }
+ _, _ = testPut(ctx, t, f, &fileToPurge)
+
+ fstest.CheckListingWithPrecision(t, f, []fstest.Item{file1, file2, fileToPurge}, []string{
+ "dirToPurgeFromRoot",
+ "hello? sausage",
+ "hello? sausage/êé",
+ "hello? sausage/êé/Hello, 世界",
+ "hello? sausage/êé/Hello, 世界/ \" ' @ < > & ? + ≠",
+ }, fs.GetModifyWindow(ctx, f))
+
+ // Create a new Fs pointing at the directory
+ remoteName := subRemoteName + "/" + "dirToPurgeFromRoot"
+ fPurge, err := fs.NewFs(context.Background(), remoteName)
+ require.NoError(t, err)
+
+ // Now purge it from the root
+ err = operations.Purge(ctx, fPurge, "")
+ require.NoError(t, err)
+
+ fstest.CheckListingWithPrecision(t, f, []fstest.Item{file1, file2}, []string{
+ "hello? sausage",
+ "hello? sausage/êé",
+ "hello? sausage/êé/Hello, 世界",
+ "hello? sausage/êé/Hello, 世界/ \" ' @ < > & ? + ≠",
+ }, fs.GetModifyWindow(ctx, f))
+ })
+
// TestFsCopy tests Copy
t.Run("FsCopy", func(t *testing.T) {
skipIfNotOk(t)