sync: fix tests for overlapping with filter

In commit

3ccf222acb sync: overlap check is now filter-sensitive

The tests were attempting to write invalid objects on some backends
due to a leading / on the object name.

This fix also adds a few more test cases and makes sure the tests can
be run individually.
This commit is contained in:
Nick Craig-Wood 2022-06-09 13:19:11 +01:00
parent 7c1f2d7c84
commit cfe0911e0d
2 changed files with 6 additions and 1 deletions

View File

@ -1284,6 +1284,7 @@ func TestOverlappingFilterCheckWithoutFilter(t *testing.T) {
expected bool
}{
{"name", "root", true},
{"name", "/root", true},
{"namey", "root", false},
{"name", "rooty", false},
{"namey", "rooty", false},
@ -1320,10 +1321,12 @@ func TestOverlappingFilterCheckWithFilter(t *testing.T) {
expected bool
}{
{"name", "root", true},
{"name", "/root", true},
{"name", "root/", true},
{"name", "root" + slash, true},
{"name", "root/exclude", false},
{"name", "root/exclude/", false},
{"name", "/root/exclude/", false},
{"name", "root" + slash + "exclude", false},
{"name", "root" + slash + "exclude" + slash, false},
{"name", "root/.ignore", false},

View File

@ -1469,18 +1469,20 @@ func TestSyncOverlapWithFilter(t *testing.T) {
FremoteSync3, err := fs.NewFs(ctx, subRemoteName3)
require.NoError(t, FremoteSync3.Mkdir(ctx, ""))
require.NoError(t, err)
r.WriteObject(context.Background(), "/rclone-sync-test-ignore-file/.ignore", "-", t1)
r.WriteObject(context.Background(), "rclone-sync-test-ignore-file/.ignore", "-", t1)
checkErr := func(err error) {
require.Error(t, err)
assert.True(t, fserrors.IsFatalError(err))
assert.Equal(t, fs.ErrorOverlapping.Error(), err.Error())
accounting.GlobalStats().ResetCounters()
}
checkNoErr := func(err error) {
require.NoError(t, err)
}
accounting.GlobalStats().ResetCounters()
checkNoErr(Sync(ctx, FremoteSync, r.Fremote, false))
checkErr(Sync(ctx, r.Fremote, FremoteSync, false))
checkErr(Sync(ctx, r.Fremote, r.Fremote, false))