Skip to content

Commit

Permalink
Implement unit test for #9311
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Mar 9, 2023
1 parent 064c8e8 commit 049cb5a
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,58 @@ private slots:

QCOMPARE(QFileInfo(fakeFolder.localPath() + "foo").lastModified(), datetime);
}


#ifdef Q_OS_WIN
void testProceedWithIndependentDelets()
{
QFETCH_GLOBAL(Vfs::Mode, vfsMode);
QFETCH_GLOBAL(bool, filesAreDehydrated);

FakeFolder fakeFolder(FileInfo::A12_B12_C12_S12(), vfsMode, filesAreDehydrated);
fakeFolder.remoteModifier().mkdir(QStringLiteral("A/JustAFolder"));
fakeFolder.remoteModifier().insert(QStringLiteral("A/JustAFolder/WithFiles"));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());


QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A")));
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("B")));
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("S")));

const auto lockedFileName = QStringLiteral("A/locked");
fakeFolder.localModifier().insert(lockedFileName);

QVERIFY(fakeFolder.applyLocalModificationsAndSync());

// lock the file to trigger a sync error
auto lock = FileSystem::lockFile(fakeFolder.localPath() + lockedFileName, FileSystem::LockMode::Exclusive);
QVERIFY(lock);

fakeFolder.remoteModifier().insert(QStringLiteral("B/bb"));
fakeFolder.remoteModifier().remove(QStringLiteral("S"));

fakeFolder.remoteModifier().remove(QStringLiteral("A"));
// ensure we have a job in addition to the remove
fakeFolder.localModifier().insert("A/newFile");

QVERIFY(!fakeFolder.applyLocalModificationsAndSync());
lock.close();

// we still have the clashed item
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A")));
QVERIFY(fakeFolder.currentLocalState().find(lockedFileName));

// the unaffected download happened
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("B/bb")));

// the remove did not happen as we had a case clash
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("A")));

// S was deleted independent of the clas of A/aa and A/aA
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("S")));
}
#endif
};

QTEST_GUILESS_MAIN(TestSyncEngine)
Expand Down

0 comments on commit 049cb5a

Please sign in to comment.