From ff5261eaf142bd725d2a2076fc152d0389f2349d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Sep 2022 13:06:16 +0200 Subject: [PATCH] Check local file locked and unlocked correctly in testlocaldiscovery Signed-off-by: Claudio Cambra --- test/testlocaldiscovery.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/test/testlocaldiscovery.cpp b/test/testlocaldiscovery.cpp index bc066aefc..80350bf90 100644 --- a/test/testlocaldiscovery.cpp +++ b/test/testlocaldiscovery.cpp @@ -620,14 +620,16 @@ private slots: const QString barFileAaaSubFolder("aaa/subfolder/bar"); fakeFolder.remoteModifier().insert(fooFileRootFolder); - fakeFolder.remoteModifier().insert(barFileRootFolder); - fakeFolder.remoteModifier().find("bar")->extraDavProperties = "1" - "0" - "user1" - "user1" - "user1" - "1648046707"; + + const auto lockedFileDavProps = QByteArray("1" + "0" + "user1" + "user1" + "user1" + "1648046707"); + + fakeFolder.remoteModifier().find("bar")->extraDavProperties = lockedFileDavProps; fakeFolder.remoteModifier().mkdir(QStringLiteral("subfolder")); fakeFolder.remoteModifier().insert(fooFileSubFolder); @@ -637,12 +639,26 @@ private slots: fakeFolder.remoteModifier().insert(fooFileAaaSubFolder); fakeFolder.remoteModifier().insert(barFileAaaSubFolder); - QVERIFY(fakeFolder.syncOnce()); + ItemCompletedSpy completeSpy(fakeFolder); - fakeFolder.remoteModifier().find("bar")->extraDavProperties = "0"; + completeSpy.clear(); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(completeSpy.findItem("bar")->_locked, OCC::SyncFileItem::LockStatus::LockedItem); + SyncJournalFileRecord fileRecordBefore; + QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("bar"), &fileRecordBefore)); + QVERIFY(fileRecordBefore._lockstate._locked); + + const auto unlockedFileDavProps = QByteArray("0"); + fakeFolder.remoteModifier().find("bar")->extraDavProperties = unlockedFileDavProps; fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem); + + completeSpy.clear(); QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(completeSpy.findItem("bar")->_locked, OCC::SyncFileItem::LockStatus::UnlockedItem); + SyncJournalFileRecord fileRecordAfter; + QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("bar"), &fileRecordAfter)); + QVERIFY(!fileRecordAfter._lockstate._locked); } };