mirror of
https://github.com/rclone/rclone.git
synced 2025-06-19 03:16:49 +02:00
operations: skip backends incapable of testing TestApplyTransforms - #7591
This adds a step to detect whether the backend is capable of supporting the feature, and skips the test if not. A backend can be incapable if, for example, it is non-case-preserving or automatically converts NFD to NFC.
This commit is contained in:
parent
f4c058e13e
commit
dfe76570a1
@ -568,6 +568,13 @@ func TestApplyTransforms(t *testing.T) {
|
|||||||
opt := operations.CheckOpt{}
|
opt := operations.CheckOpt{}
|
||||||
|
|
||||||
remotefile := r.WriteObject(ctx, remotefileName, content, t2)
|
remotefile := r.WriteObject(ctx, remotefileName, content, t2)
|
||||||
|
// test whether remote is capable of running test
|
||||||
|
entries, err := r.Fremote.List(ctx, "")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
if entries.Len() == 1 && entries[0].Remote() != remotefileName {
|
||||||
|
t.Skipf("Fs is incapable of running test, skipping: %s (expected: %s (%s) actual: %s (%s))", scenario, remotefileName, detectEncoding(remotefileName), entries[0].Remote(), detectEncoding(entries[0].Remote()))
|
||||||
|
}
|
||||||
|
|
||||||
checkfile := r.WriteFile("test.sum", hash+" "+checkfileName, t2)
|
checkfile := r.WriteFile("test.sum", hash+" "+checkfileName, t2)
|
||||||
r.CheckLocalItems(t, checkfile)
|
r.CheckLocalItems(t, checkfile)
|
||||||
assert.False(t, checkfileName == remotefile.Path, "Values match but should not: %s %s", checkfileName, remotefile.Path)
|
assert.False(t, checkfileName == remotefile.Path, "Values match but should not: %s %s", checkfileName, remotefile.Path)
|
||||||
@ -577,7 +584,7 @@ func TestApplyTransforms(t *testing.T) {
|
|||||||
ci.NoUnicodeNormalization = true
|
ci.NoUnicodeNormalization = true
|
||||||
ci.IgnoreCaseSync = false
|
ci.IgnoreCaseSync = false
|
||||||
accounting.GlobalStats().ResetCounters()
|
accounting.GlobalStats().ResetCounters()
|
||||||
err := operations.CheckSum(ctx, r.Fremote, r.Flocal, "test.sum", hashType, &opt, true)
|
err = operations.CheckSum(ctx, r.Fremote, r.Flocal, "test.sum", hashType, &opt, true)
|
||||||
assert.Error(t, err, "no expected error for %s %v %v", testname, checkfileName, remotefileName)
|
assert.Error(t, err, "no expected error for %s %v %v", testname, checkfileName, remotefileName)
|
||||||
|
|
||||||
testname = scenario + " (with normalization)"
|
testname = scenario + " (with normalization)"
|
||||||
@ -600,3 +607,16 @@ func TestApplyTransforms(t *testing.T) {
|
|||||||
testScenario(both, nfdx2, "both checkfile vs. NFDx2 remote")
|
testScenario(both, nfdx2, "both checkfile vs. NFDx2 remote")
|
||||||
testScenario(both, nfcx2, "both checkfile vs. NFCx2 remote")
|
testScenario(both, nfcx2, "both checkfile vs. NFCx2 remote")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func detectEncoding(s string) string {
|
||||||
|
if norm.NFC.IsNormalString(s) && norm.NFD.IsNormalString(s) {
|
||||||
|
return "BOTH"
|
||||||
|
}
|
||||||
|
if !norm.NFC.IsNormalString(s) && norm.NFD.IsNormalString(s) {
|
||||||
|
return "NFD"
|
||||||
|
}
|
||||||
|
if norm.NFC.IsNormalString(s) && !norm.NFD.IsNormalString(s) {
|
||||||
|
return "NFC"
|
||||||
|
}
|
||||||
|
return "OTHER"
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user