From: Claudio Cambra Date: Fri, 28 Jul 2023 17:04:58 +0000 (+0800) Subject: Add test for Chunk V2 restrictions in testchunkingng X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~9^2~24^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=eb01a573599e53af26d52496612dd0be17c9eeb1;p=nextcloud-desktop.git Add test for Chunk V2 restrictions in testchunkingng Signed-off-by: Claudio Cambra --- diff --git a/test/testchunkingng.cpp b/test/testchunkingng.cpp index f76005184..913d9f12e 100644 --- a/test/testchunkingng.cpp +++ b/test/testchunkingng.cpp @@ -5,8 +5,9 @@ * */ -#include #include "syncenginetestutils.h" +#include +#include #include using namespace OCC; @@ -54,8 +55,44 @@ class TestChunkingNG : public QObject Q_OBJECT private slots: + void testChunkV2Restrictions() + { + FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()}; + fakeFolder.syncEngine().account()->setCapabilities({{"dav", QVariantMap{{"chunking", "1.0"}}}}); + + constexpr auto maxChunkSize = 5LL * 1000LL * 1000LL * 1000LL; + ::setChunkSize(fakeFolder.syncEngine(), 10LL * 1000LL * 1000LL * 1000LL); + QCOMPARE(fakeFolder.syncEngine().syncOptions().maxChunkSize(), maxChunkSize); + + constexpr auto minChunkSize = 5 * 1000 * 1000; + ::setChunkSize(fakeFolder.syncEngine(), 1 * 1000 * 1000); + QCOMPARE(fakeFolder.syncEngine().syncOptions().minChunkSize(), minChunkSize); + + auto hasDestinationHeader = false; + fakeFolder.setServerOverride( + [&hasDestinationHeader](const QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *const) -> QNetworkReply * { + if (op == QNetworkAccessManager::PutOperation) { + qDebug() << "Request headers:" << request.rawHeaderList(); + hasDestinationHeader |= request.hasRawHeader("Destination"); + } + return nullptr; + }); + + constexpr auto size = 1000 * 1000 * 1000; // 100 MB + ::partialUpload(fakeFolder, "A/a0", size); - void testFileUpload() { + QVERIFY(hasDestinationHeader); + + QCOMPARE(fakeFolder.uploadState().children.count(), 1); + const auto chunkingId = fakeFolder.uploadState().children.first().name; + const auto chunkMap = fakeFolder.uploadState().children.first().children; + const auto firstChunkName = chunkMap.first().name; + const auto expectedChunkName = QString("%1").arg(1, 5, 10, QChar('0')); + QCOMPARE(firstChunkName, expectedChunkName); + } + + void testFileUpload() + { FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()}; fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } }); setChunkSize(fakeFolder.syncEngine(), 1 * 1000 * 1000);