diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2018-10-16 17:00:59 +0300 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2018-10-16 17:00:59 +0300 |
commit | 24c717c62866dbb128d28d52eff9dc14d8788059 (patch) | |
tree | 2bc62348efb9ac853936460e1f73b8a49cd1d14e /test/testsyncconflict.cpp | |
parent | 4fd9f3b21d34720a9f5417989122a2a56436186e (diff) |
Discovery: Remove stale DB entries
And test the Remove/Remove case.
This means we need to always query the database for all the entries.
This showed another small bug in the test in which sync item for virtual
files at the root could have a slash in front of them.
Diffstat (limited to 'test/testsyncconflict.cpp')
-rw-r--r-- | test/testsyncconflict.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/testsyncconflict.cpp b/test/testsyncconflict.cpp index 9052592ef..5d6458ea7 100644 --- a/test/testsyncconflict.cpp +++ b/test/testsyncconflict.cpp @@ -64,6 +64,13 @@ bool expectAndWipeConflict(FileModifier &local, FileInfo state, const QString pa return false; } +SyncJournalFileRecord dbRecord(FakeFolder &folder, const QString &path) +{ + SyncJournalFileRecord record; + folder.syncJournal().getFileRecord(path, &record); + return record; +} + class TestSyncConflict : public QObject { Q_OBJECT @@ -600,6 +607,30 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + + // Test what happens if we remove entries both on the server, and locally + void testRemoveRemove() + { + FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() }; + fakeFolder.remoteModifier().remove("A"); + fakeFolder.localModifier().remove("A"); + fakeFolder.remoteModifier().remove("B/b1"); + fakeFolder.localModifier().remove("B/b1"); + + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + auto expectedState = fakeFolder.currentLocalState(); + + QVERIFY(fakeFolder.syncOnce()); + + QCOMPARE(fakeFolder.currentLocalState(), expectedState); + QCOMPARE(fakeFolder.currentRemoteState(), expectedState); + + QVERIFY(dbRecord(fakeFolder, "B/b2").isValid()); + + QVERIFY(!dbRecord(fakeFolder, "B/b1").isValid()); + QVERIFY(!dbRecord(fakeFolder, "A/a1").isValid()); + QVERIFY(!dbRecord(fakeFolder, "A").isValid()); + } }; QTEST_GUILESS_MAIN(TestSyncConflict) |