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

sync: fix one transform test error failing all the following tests

Nick Craig-Wood4db5b916107c
diff --git a/fs/sync/sync_transform_test.go b/fs/sync/sync_transform_test.go
index 0def4d2d7..c316f434e 100644
--- a/fs/sync/sync_transform_test.go
+++ b/fs/sync/sync_transform_test.go
@@ -26,6 +26,15 @@ import (
var debug = ``
+// newTransformRun resets the global error stats, which Sync consults
+// before deleting files, so that an error left over from an earlier
+// test in this binary doesn't disable deletions in this one, then
+// creates a new test run.
+func newTransformRun(t *testing.T) *fstest.Run {
+ accounting.GlobalStats().ResetCounters()
+ return fstest.NewRun(t)
+}
+
func TestTransform(t *testing.T) {
type args struct {
TransformOpt []string
@@ -94,7 +103,7 @@ func TestTransform(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
defer r.Finalise()
ctx := context.Background()
@@ -228,7 +237,7 @@ func detectEncoding(s string) string {
func TestTransformCopy(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "all,suffix_keep_extension=_somesuffix")
require.NoError(t, err)
file1 := r.WriteFile("sub dir/hello world.txt", "hello world", t1)
@@ -245,7 +254,7 @@ func TestTransformCopy(t *testing.T) {
func TestDoubleTransform(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "all,prefix=tac", "all,prefix=tic")
require.NoError(t, err)
file1 := r.WriteFile("toe/toe", "hello world", t1)
@@ -262,7 +271,7 @@ func TestDoubleTransform(t *testing.T) {
func TestFileTag(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "file,prefix=tac", "file,prefix=tic")
require.NoError(t, err)
file1 := r.WriteFile("toe/toe/toe", "hello world", t1)
@@ -279,7 +288,7 @@ func TestFileTag(t *testing.T) {
func TestNoTag(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "prefix=tac", "prefix=tic")
require.NoError(t, err)
file1 := r.WriteFile("toe/toe/toe", "hello world", t1)
@@ -296,7 +305,7 @@ func TestNoTag(t *testing.T) {
func TestDirTag(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "dir,prefix=tac", "dir,prefix=tic")
require.NoError(t, err)
r.WriteFile("toe/toe/toe.txt", "hello world", t1)
@@ -315,7 +324,7 @@ func TestDirTag(t *testing.T) {
func TestAllTag(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "all,prefix=tac", "all,prefix=tic")
require.NoError(t, err)
r.WriteFile("toe/toe/toe.txt", "hello world", t1)
@@ -336,7 +345,7 @@ func TestAllTag(t *testing.T) {
func TestRunTwice(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "dir,prefix=tac", "dir,prefix=tic")
require.NoError(t, err)
file1 := r.WriteFile("toe/toe/toe.txt", "hello world", t1)
@@ -377,7 +386,7 @@ func TestSyntax(t *testing.T) {
func TestConflicting(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "prefix=tac", "trimprefix=tac")
require.NoError(t, err)
file1 := r.WriteFile("toe/toe/toe", "hello world", t1)
@@ -395,7 +404,7 @@ func TestConflicting(t *testing.T) {
func TestMove(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "all,prefix=tac", "all,prefix=tic")
require.NoError(t, err)
r.WriteFile("toe/toe/toe.txt", "hello world", t1)
@@ -414,7 +423,7 @@ func TestMove(t *testing.T) {
func TestTransformFile(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "all,prefix=tac", "all,prefix=tic")
require.NoError(t, err)
r.WriteFile("toe/toe/toe.txt", "hello world", t1)
@@ -443,7 +452,7 @@ func TestTransformFile(t *testing.T) {
func TestManualTransformFile(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
r.Flocal.Features().DisableList([]string{"Copy", "Move"})
r.Fremote.Features().DisableList([]string{"Copy", "Move"})
@@ -476,7 +485,7 @@ func TestManualTransformFile(t *testing.T) {
func TestBase64(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "all,base64encode")
require.NoError(t, err)
file1 := r.WriteFile("toe/toe/toe.txt", "hello world", t1)
@@ -504,7 +513,7 @@ func TestBase64(t *testing.T) {
func TestError(t *testing.T) {
ctx := context.Background()
- r := fstest.NewRun(t)
+ r := newTransformRun(t)
err := transform.SetOptions(ctx, "all,prefix=ta/c") // has illegal character
require.NoError(t, err)
file1 := r.WriteFile("toe/toe/toe", "hello world", t1)