Skip to content

Commit

Permalink
Fix renaming tests for files under group folders.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <[email protected]>
  • Loading branch information
camilasan committed Jun 25, 2024
1 parent 1525c11 commit 008d531
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions test/testsyncmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,45 +322,41 @@ private slots:

void testLocalExternalStorageRenameDetection()
{
FakeFolder fakeFolder { FileInfo { QString(), { FileInfo { QStringLiteral("external") } } }};

int nPUT = 0;
int nDELETE = 0;
fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &, QIODevice *) {
if (op == QNetworkAccessManager::PutOperation) {
++nPUT;
}

if (op == QNetworkAccessManager::DeleteOperation) {
++nDELETE;
}
return nullptr;
});

fakeFolder.remoteModifier().permissions.setPermission(OCC::RemotePermissions::IsMounted);
fakeFolder.remoteModifier().permissions.setPermission(OCC::RemotePermissions::CanMove);
fakeFolder.remoteModifier().permissions.setPermission(OCC::RemotePermissions::CanWrite);
FakeFolder fakeFolder{{}};
fakeFolder.remoteModifier().mkdir("external-storage");
auto externalStorage = fakeFolder.remoteModifier().find("external-storage");
externalStorage->extraDavProperties = "<nc:is-mount-root>true</nc:is-mount-root>";
setAllPerm(externalStorage, RemotePermissions::fromServerString("WDNVCKRM"));
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.remoteModifier());

fakeFolder.localModifier().insert("external/file", 100);
OperationCounter operationCounter;
fakeFolder.setServerOverride(operationCounter.functor());

fakeFolder.localModifier().insert("external-storage/file", 100);
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.remoteModifier()));
QCOMPARE(nPUT, 1);
QCOMPARE(operationCounter.nPUT, 1);

const auto firstFileId = fakeFolder.remoteModifier().find("external-storage/file")->fileId;

fakeFolder.localModifier().rename("external/file", "external/file2");
fakeFolder.localModifier().rename("external/file2", "external/file3");
fakeFolder.localModifier().rename("external-storage/file", "external-storage/file2");
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(operationCounter.nMOVE, 1);

fakeFolder.localModifier().rename("external-storage/file2", "external-storage/file3");
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(operationCounter.nMOVE, 2);

const auto renamedFileId = fakeFolder.remoteModifier().find("external-storage/file3")->fileId;

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.remoteModifier()));
QCOMPARE(fakeFolder.remoteModifier().children.size(), 1);

QCOMPARE(fakeFolder.remoteModifier().children.size(), 1);
QCOMPARE(fakeFolder.remoteModifier().children.value("external").children.size(), 1);
QCOMPARE(fakeFolder.remoteModifier().children.value("external").children.value("file3").name, QStringLiteral("file3"));
QCOMPARE(nPUT, 1);
QCOMPARE(nDELETE, 0);
QCOMPARE(fakeFolder.remoteModifier().find("external-storage/file"), nullptr);
QCOMPARE(fakeFolder.remoteModifier().find("external-storage/file2"), nullptr);
QVERIFY(fakeFolder.remoteModifier().find("external-storage/file3"));
QCOMPARE(firstFileId, renamedFileId);
}

void testDuplicateFileId_data()
Expand Down

0 comments on commit 008d531

Please sign in to comment.