Skip to content

Commit

Permalink
add new test to simulate the data loss scenario
Browse files Browse the repository at this point in the history
this new test trigger the assert that a file is either in the old place
or the new place when we execute a MOVE instruction for a local file

in the test one file is discovered as in need of a local MOVE but will
be missing from the old and new places when running the propagation due
to a bug

Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Mar 5, 2024
1 parent 976dbd6 commit b35a260
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/testsyncmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,66 @@ private slots:

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}

void testRenameSameFileInMultiplePaths()
{
FakeFolder fakeFolder{FileInfo{}};

fakeFolder.remoteModifier().mkdir("FolderA");
fakeFolder.remoteModifier().mkdir("FolderA/folderParent");
fakeFolder.remoteModifier().mkdir("FolderB");
fakeFolder.remoteModifier().mkdir("FolderB/folderChild");
fakeFolder.remoteModifier().insert("FolderB/folderChild/FileA.txt");
fakeFolder.remoteModifier().mkdir("FolderC");

const auto folderParentFileInfo = fakeFolder.remoteModifier().find("FolderA/folderParent");
const auto folderParentSharedFolderFileId = folderParentFileInfo->fileId;
const auto folderParentSharedFolderEtag = folderParentFileInfo->etag;
const auto folderChildFileInfo = fakeFolder.remoteModifier().find("FolderB/folderChild");
const auto folderChildInFolderAFolderFileId = folderChildFileInfo->fileId;
const auto folderChildInFolderAEtag = folderChildFileInfo->etag;
const auto fileAFileInfo = fakeFolder.remoteModifier().find("FolderB/folderChild/FileA.txt");
const auto fileAInFolderAFolderFileId = fileAFileInfo->fileId;
const auto fileAInFolderAEtag = fileAFileInfo->etag;

auto folderCFileInfo = fakeFolder.remoteModifier().find("FolderC");
folderCFileInfo->fileId = folderParentSharedFolderFileId;
folderCFileInfo->etag = folderParentSharedFolderEtag;

QVERIFY(fakeFolder.syncOnce());

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());

fakeFolder.remoteModifier().remove("FolderB/folderChild");
fakeFolder.remoteModifier().mkdir("FolderA/folderParent/folderChild");
fakeFolder.remoteModifier().insert("FolderA/folderParent/folderChild/FileA.txt");
fakeFolder.remoteModifier().mkdir("FolderC/folderChild");
fakeFolder.remoteModifier().insert("FolderC/folderChild/FileA.txt");

auto folderChildInFolderParentFileInfo = fakeFolder.remoteModifier().find("FolderA/folderParent/folderChild");
folderChildInFolderParentFileInfo->fileId = folderChildInFolderAFolderFileId;
folderChildInFolderParentFileInfo->etag = folderChildInFolderAEtag;

auto fileAInFolderParentFileInfo = fakeFolder.remoteModifier().find("FolderA/folderParent/folderChild/FileA.txt");
fileAInFolderParentFileInfo->fileId = fileAInFolderAFolderFileId;
fileAInFolderParentFileInfo->etag = fileAInFolderAEtag;

auto folderChildInFolderCFileInfo = fakeFolder.remoteModifier().find("FolderC/folderChild");
folderChildInFolderCFileInfo->fileId = folderChildInFolderAFolderFileId;
folderChildInFolderCFileInfo->etag = folderChildInFolderAEtag;

auto fileAInFolderCFileInfo = fakeFolder.remoteModifier().find("FolderC/folderChild/FileA.txt");
fileAInFolderCFileInfo->fileId = fileAInFolderAFolderFileId;
fileAInFolderCFileInfo->etag = fileAInFolderAEtag;

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly);
QVERIFY(fakeFolder.syncOnce());

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly);
QVERIFY(fakeFolder.syncOnce());

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
};

QTEST_GUILESS_MAIN(TestSyncMove)
Expand Down

0 comments on commit b35a260

Please sign in to comment.