Skip to content

Commit

Permalink
Tests for Bugfix of non-root remote path sync for E2EE.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Feb 24, 2024
1 parent 3671582 commit 97ac724
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/testutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,54 @@ private slots:
QVERIFY(!isPathWindowsDrivePartitionRoot("c:\\"));
#endif
}

void testFullRemotePathToRemoteSyncRootRelative()
{
QVector<QPair<QString, QString>> remoteFullPathsForRoot = {
{"2020", {"2020"}},
{"/2021/", {"2021"}},
{"/2022/file.docx", {"2022/file.docx"}}
};
// test against root remote path - result must stay unchanged, leading and trailing slashes must get removed
for (const auto &remoteFullPathForRoot : remoteFullPathsForRoot) {
const auto fullRemotePathOriginal = remoteFullPathForRoot.first;
const auto fullRemotePathExpected = remoteFullPathForRoot.second;
const auto fullRepotePathResult = OCC::Utility::fullRemotePathToRemoteSyncRootRelative(fullRemotePathOriginal, "/");
QCOMPARE(fullRepotePathResult, fullRemotePathExpected);
}

QString remotePathNonRoot = "/Documents/reports";
QVector<QPair<QString, QString>> remoteFullPathsForNonRoot = {
{remotePathNonRoot + "/" + "2020", {"2020"}},
{remotePathNonRoot + "/" + "2021/", {"2021"}},
{remotePathNonRoot + "/" + "2022/file.docx", {"2022/file.docx"}}
};

// test against non-root remote path - must always return a proper path as in local db
for (const auto &remoteFullPathForNonRoot : remoteFullPathsForNonRoot) {
const auto fullRemotePathOriginal = remoteFullPathForNonRoot.first;
const auto fullRemotePathExpected = remoteFullPathForNonRoot.second;
const auto fullRepotePathResult = OCC::Utility::fullRemotePathToRemoteSyncRootRelative(fullRemotePathOriginal, remotePathNonRoot);
QCOMPARE(fullRepotePathResult, fullRemotePathExpected);
}

// test against non-root remote path with trailing slash - must work the same
QString remotePathNonRootWithTrailingSlash = "/Documents/reports/";
for (const auto &remoteFullPathForNonRoot : remoteFullPathsForNonRoot) {
const auto fullRemotePathOriginal = remoteFullPathForNonRoot.first;
const auto fullRemotePathExpected = remoteFullPathForNonRoot.second;
const auto fullRepotePathResult = OCC::Utility::fullRemotePathToRemoteSyncRootRelative(fullRemotePathOriginal, remotePathNonRootWithTrailingSlash);
QCOMPARE(fullRepotePathResult, fullRemotePathExpected);
}

// test against unrelated remote path - result must stay unchanged
QString remotePathUnrelated = "/Documents1/reports";
for (const auto &remoteFullPathForNonRoot : remoteFullPathsForNonRoot) {
const auto fullRemotePathOriginal = remoteFullPathForNonRoot.first;
const auto fullRepotePathResult = OCC::Utility::fullRemotePathToRemoteSyncRootRelative(fullRemotePathOriginal, remotePathUnrelated);
QCOMPARE(fullRepotePathResult, fullRemotePathOriginal);
}
}
};

QTEST_GUILESS_MAIN(TestUtility)
Expand Down

0 comments on commit 97ac724

Please sign in to comment.