mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 14:05:58 +03:00
Do not ignore return values for SyncJournalDB in unit tests.
Signed-off-by: allexzander <blackslayer4@gmail.com>
This commit is contained in:
parent
65cd8d06bc
commit
5175d186a4
12 changed files with 57 additions and 61 deletions
|
@ -1198,7 +1198,7 @@ static FileInfo &findOrCreateDirs(FileInfo &base, PathComponents components)
|
|||
FileInfo FakeFolder::dbState() const
|
||||
{
|
||||
FileInfo result;
|
||||
_journalDb->getFilesBelowPath("", [&](const OCC::SyncJournalFileRecord &record) {
|
||||
[[maybe_unused]] const auto journalDbResult =_journalDb->getFilesBelowPath("", [&](const OCC::SyncJournalFileRecord &record) {
|
||||
auto components = PathComponents(record.path());
|
||||
auto &parentDir = findOrCreateDirs(result, components.parentDirComponents());
|
||||
auto name = components.fileName();
|
||||
|
|
|
@ -177,7 +177,7 @@ private slots:
|
|||
return waitAndChain(waitForeverCallback)(tc, request);
|
||||
})));
|
||||
|
||||
fakeFolder.syncJournal().wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncJournal().wipeErrorBlacklist() != -1);
|
||||
|
||||
// This second sync will redo the files that had errors
|
||||
// But the waiting folder will not complete before it is aborted.
|
||||
|
|
|
@ -14,7 +14,7 @@ using namespace OCC;
|
|||
SyncJournalFileRecord journalRecord(FakeFolder &folder, const QByteArray &path)
|
||||
{
|
||||
SyncJournalFileRecord rec;
|
||||
folder.syncJournal().getFileRecord(path, &rec);
|
||||
[[maybe_unused]] const auto result = folder.syncJournal().getFileRecord(path, &rec);
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ private slots:
|
|||
QVERIFY(realFolder);
|
||||
for (const auto &dummyImageName : dummmyImageNames) {
|
||||
if (fakeFolder.syncJournal().getFileRecord(dummyImageName, &record)) {
|
||||
realFolder->journalDb()->setFileRecord(record);
|
||||
QVERIFY(realFolder->journalDb()->setFileRecord(record));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ private slots:
|
|||
QVERIFY(!trackerContains("A/spurious")); // removed due to full discovery
|
||||
|
||||
fakeFolder.serverErrorPaths().clear();
|
||||
fakeFolder.syncJournal().wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncJournal().wipeErrorBlacklist() != -1);
|
||||
tracker.addTouchedPath("A/newspurious"); // will be removed due to successful sync
|
||||
|
||||
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, tracker.localDiscoveryPaths());
|
||||
|
|
|
@ -67,7 +67,7 @@ bool itemInstruction(const ItemCompletedSpy &spy, const QString &path, const Syn
|
|||
SyncJournalFileRecord dbRecord(FakeFolder &folder, const QString &path)
|
||||
{
|
||||
SyncJournalFileRecord record;
|
||||
folder.syncJournal().getFileRecord(path, &record);
|
||||
[[maybe_unused]] const auto result = folder.syncJournal().getFileRecord(path, &record);
|
||||
return record;
|
||||
}
|
||||
|
||||
|
@ -75,11 +75,11 @@ void triggerDownload(FakeFolder &folder, const QByteArray &path)
|
|||
{
|
||||
auto &journal = folder.syncJournal();
|
||||
SyncJournalFileRecord record;
|
||||
journal.getFileRecord(path, &record);
|
||||
if (!record.isValid())
|
||||
if (!journal.getFileRecord(path, &record) || !record.isValid()) {
|
||||
return;
|
||||
}
|
||||
record._type = ItemTypeVirtualFileDownload;
|
||||
journal.setFileRecord(record);
|
||||
QVERIFY(journal.setFileRecord(record));
|
||||
journal.schedulePathForRemoteDiscovery(record._path);
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,11 @@ void markForDehydration(FakeFolder &folder, const QByteArray &path)
|
|||
{
|
||||
auto &journal = folder.syncJournal();
|
||||
SyncJournalFileRecord record;
|
||||
journal.getFileRecord(path, &record);
|
||||
if (!record.isValid())
|
||||
if (!journal.getFileRecord(path, &record) || !record.isValid()) {
|
||||
return;
|
||||
}
|
||||
record._type = ItemTypeVirtualFileDehydration;
|
||||
journal.setFileRecord(record);
|
||||
QVERIFY(journal.setFileRecord(record));
|
||||
journal.schedulePathForRemoteDiscovery(record._path);
|
||||
}
|
||||
|
||||
|
@ -237,8 +237,8 @@ private slots:
|
|||
QCOMPARE(QFileInfo(fakeFolder.localPath() + "A/a3").size(), 33);
|
||||
cleanup();
|
||||
|
||||
fakeFolder.syncEngine().journal()->deleteFileRecord("A/a2");
|
||||
fakeFolder.syncEngine().journal()->deleteFileRecord("A/a3");
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->deleteFileRecord("A/a2"));
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->deleteFileRecord("A/a3"));
|
||||
fakeFolder.remoteModifier().remove("A/a3");
|
||||
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::FilesystemOnly);
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
@ -456,7 +456,7 @@ private slots:
|
|||
|
||||
auto cleanup = [&]() {
|
||||
completeSpy.clear();
|
||||
fakeFolder.syncJournal().wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncJournal().wipeErrorBlacklist() != -1);
|
||||
};
|
||||
cleanup();
|
||||
|
||||
|
@ -735,8 +735,7 @@ private slots:
|
|||
};
|
||||
auto hasDehydratedDbEntries = [&](const QString &path) {
|
||||
SyncJournalFileRecord rec;
|
||||
fakeFolder.syncJournal().getFileRecord(path, &rec);
|
||||
return rec.isValid() && rec._type == ItemTypeVirtualFile;
|
||||
return fakeFolder.syncJournal().getFileRecord(path, &rec) && rec.isValid() && rec._type == ItemTypeVirtualFile;
|
||||
};
|
||||
|
||||
QVERIFY(isDehydrated("A/a1"));
|
||||
|
|
|
@ -57,7 +57,7 @@ bool expectAndWipeConflict(FileModifier &local, FileInfo state, const QString pa
|
|||
SyncJournalFileRecord dbRecord(FakeFolder &folder, const QString &path)
|
||||
{
|
||||
SyncJournalFileRecord record;
|
||||
folder.syncJournal().getFileRecord(path, &record);
|
||||
[[maybe_unused]] const auto result = folder.syncJournal().getFileRecord(path, &record);
|
||||
return record;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ private slots:
|
|||
|
||||
auto getDbChecksum = [&](QString path) {
|
||||
SyncJournalFileRecord record;
|
||||
fakeFolder.syncJournal().getFileRecord(path, &record);
|
||||
[[maybe_unused]] const auto result = fakeFolder.syncJournal().getFileRecord(path, &record);
|
||||
return record._checksumHeader;
|
||||
};
|
||||
|
||||
|
@ -275,7 +275,7 @@ private slots:
|
|||
fakeFolder.syncEngine().journal()->schedulePathForRemoteDiscovery(QByteArrayLiteral("parentFolder/subFolderA/"));
|
||||
auto getEtag = [&](const QByteArray &file) {
|
||||
SyncJournalFileRecord rec;
|
||||
fakeFolder.syncJournal().getFileRecord(file, &rec);
|
||||
[[maybe_unused]] const auto result = fakeFolder.syncJournal().getFileRecord(file, &rec);
|
||||
return rec._etag;
|
||||
};
|
||||
QVERIFY(getEtag("parentFolder") == "_invalid_");
|
||||
|
@ -336,8 +336,7 @@ private slots:
|
|||
QVERIFY(!fakeFolder.syncOnce());
|
||||
|
||||
SyncJournalFileRecord rec;
|
||||
fakeFolder.syncJournal().getFileRecord(QByteArrayLiteral("NewFolder"), &rec);
|
||||
QVERIFY(rec.isValid());
|
||||
QVERIFY(fakeFolder.syncJournal().getFileRecord(QByteArrayLiteral("NewFolder"), &rec) && rec.isValid());
|
||||
QCOMPARE(rec._etag, QByteArrayLiteral("_invalid_"));
|
||||
QVERIFY(!rec._fileId.isEmpty());
|
||||
}
|
||||
|
@ -454,7 +453,7 @@ private slots:
|
|||
// check that mtime in journal and filesystem agree
|
||||
QString a1path = fakeFolder.localPath() + "A/a1";
|
||||
SyncJournalFileRecord a1record;
|
||||
fakeFolder.syncJournal().getFileRecord(QByteArray("A/a1"), &a1record);
|
||||
QVERIFY(fakeFolder.syncJournal().getFileRecord(QByteArray("A/a1"), &a1record));
|
||||
QCOMPARE(a1record._modtime, (qint64)FileSystem::getModTime(a1path));
|
||||
|
||||
// Extra sync reads from db, no difference
|
||||
|
|
|
@ -68,7 +68,7 @@ private slots:
|
|||
|
||||
// Update checksum
|
||||
record._checksumHeader = "Adler32:newchecksum";
|
||||
_db.updateFileRecordChecksum("foo", "newchecksum", "Adler32");
|
||||
QVERIFY(_db.updateFileRecordChecksum("foo", "newchecksum", "Adler32"));
|
||||
QVERIFY(_db.getFileRecord(QByteArrayLiteral("foo"), &storedRecord));
|
||||
QVERIFY(storedRecord == record);
|
||||
|
||||
|
@ -81,7 +81,7 @@ private slots:
|
|||
record._fileId = "efg";
|
||||
record._remotePerm = RemotePermissions::fromDbValue("NV");
|
||||
record._fileSize = 289055;
|
||||
_db.setFileRecord(record);
|
||||
QVERIFY(_db.setFileRecord(record));
|
||||
QVERIFY(_db.getFileRecord(QByteArrayLiteral("foo"), &storedRecord));
|
||||
QVERIFY(storedRecord == record);
|
||||
|
||||
|
@ -213,11 +213,11 @@ private slots:
|
|||
record._type = type;
|
||||
record._etag = initialEtag;
|
||||
record._remotePerm = RemotePermissions::fromDbValue("RW");
|
||||
_db.setFileRecord(record);
|
||||
QVERIFY(_db.setFileRecord(record));
|
||||
};
|
||||
auto getEtag = [&](const QByteArray &path) {
|
||||
SyncJournalFileRecord record;
|
||||
_db.getFileRecord(path, &record);
|
||||
[[maybe_unused]] const auto result = _db.getFileRecord(path, &record);
|
||||
return record._etag;
|
||||
};
|
||||
|
||||
|
@ -275,7 +275,7 @@ private slots:
|
|||
SyncJournalFileRecord record;
|
||||
record._path = path;
|
||||
record._remotePerm = RemotePermissions::fromDbValue("RW");
|
||||
_db.setFileRecord(record);
|
||||
QVERIFY(_db.setFileRecord(record));
|
||||
};
|
||||
|
||||
QByteArrayList elements;
|
||||
|
@ -296,8 +296,7 @@ private slots:
|
|||
bool ok = true;
|
||||
for (const auto& elem : elements) {
|
||||
SyncJournalFileRecord record;
|
||||
_db.getFileRecord(elem, &record);
|
||||
if (!record.isValid()) {
|
||||
if (!_db.getFileRecord(elem, &record) || !record.isValid()) {
|
||||
qWarning() << "Missing record: " << elem;
|
||||
ok = false;
|
||||
}
|
||||
|
@ -305,17 +304,17 @@ private slots:
|
|||
return ok;
|
||||
};
|
||||
|
||||
_db.deleteFileRecord("moo", true);
|
||||
QVERIFY(_db.deleteFileRecord("moo", true));
|
||||
elements.removeAll("moo");
|
||||
elements.removeAll("moo/file");
|
||||
QVERIFY(checkElements());
|
||||
|
||||
_db.deleteFileRecord("fo_", true);
|
||||
QVERIFY(_db.deleteFileRecord("fo_", true));
|
||||
elements.removeAll("fo_");
|
||||
elements.removeAll("fo_/file");
|
||||
QVERIFY(checkElements());
|
||||
|
||||
_db.deleteFileRecord("foo%bar", true);
|
||||
QVERIFY(_db.deleteFileRecord("foo%bar", true));
|
||||
elements.removeAll("foo%bar");
|
||||
QVERIFY(checkElements());
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ bool itemInstruction(const ItemCompletedSpy &spy, const QString &path, const Syn
|
|||
SyncJournalFileRecord dbRecord(FakeFolder &folder, const QString &path)
|
||||
{
|
||||
SyncJournalFileRecord record;
|
||||
folder.syncJournal().getFileRecord(path, &record);
|
||||
[[maybe_unused]] const auto result = folder.syncJournal().getFileRecord(path, &record);
|
||||
return record;
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,11 @@ void triggerDownload(FakeFolder &folder, const QByteArray &path)
|
|||
{
|
||||
auto &journal = folder.syncJournal();
|
||||
SyncJournalFileRecord record;
|
||||
journal.getFileRecord(path + DVSUFFIX, &record);
|
||||
if (!record.isValid())
|
||||
if (!journal.getFileRecord(path + DVSUFFIX, &record) || !record.isValid()) {
|
||||
return;
|
||||
}
|
||||
record._type = ItemTypeVirtualFileDownload;
|
||||
journal.setFileRecord(record);
|
||||
QVERIFY(journal.setFileRecord(record));
|
||||
journal.schedulePathForRemoteDiscovery(record._path);
|
||||
}
|
||||
|
||||
|
@ -44,11 +44,11 @@ void markForDehydration(FakeFolder &folder, const QByteArray &path)
|
|||
{
|
||||
auto &journal = folder.syncJournal();
|
||||
SyncJournalFileRecord record;
|
||||
journal.getFileRecord(path, &record);
|
||||
if (!record.isValid())
|
||||
if (!journal.getFileRecord(path, &record) || !record.isValid()) {
|
||||
return;
|
||||
}
|
||||
record._type = ItemTypeVirtualFileDehydration;
|
||||
journal.setFileRecord(record);
|
||||
QVERIFY(journal.setFileRecord(record));
|
||||
journal.schedulePathForRemoteDiscovery(record._path);
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,8 @@ private slots:
|
|||
QVERIFY(fakeFolder.currentLocalState().find("A/a3" DVSUFFIX));
|
||||
cleanup();
|
||||
|
||||
fakeFolder.syncEngine().journal()->deleteFileRecord("A/a2" DVSUFFIX);
|
||||
fakeFolder.syncEngine().journal()->deleteFileRecord("A/a3" DVSUFFIX);
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->deleteFileRecord("A/a2" DVSUFFIX));
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->deleteFileRecord("A/a3" DVSUFFIX));
|
||||
fakeFolder.remoteModifier().remove("A/a3");
|
||||
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::FilesystemOnly);
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
@ -431,7 +431,7 @@ private slots:
|
|||
|
||||
auto cleanup = [&]() {
|
||||
completeSpy.clear();
|
||||
fakeFolder.syncJournal().wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncJournal().wipeErrorBlacklist() != -1);
|
||||
};
|
||||
cleanup();
|
||||
|
||||
|
@ -964,9 +964,9 @@ private slots:
|
|||
};
|
||||
auto hasDehydratedDbEntries = [&](const QString &path) {
|
||||
SyncJournalFileRecord normal, suffix;
|
||||
fakeFolder.syncJournal().getFileRecord(path, &normal);
|
||||
fakeFolder.syncJournal().getFileRecord(path + DVSUFFIX, &suffix);
|
||||
return !normal.isValid() && suffix.isValid() && suffix._type == ItemTypeVirtualFile;
|
||||
return (!fakeFolder.syncJournal().getFileRecord(path, &normal) || !normal.isValid())
|
||||
&& fakeFolder.syncJournal().getFileRecord(path + DVSUFFIX, &suffix) && suffix.isValid()
|
||||
&& suffix._type == ItemTypeVirtualFile;
|
||||
};
|
||||
|
||||
QVERIFY(isDehydrated("A/a1"));
|
||||
|
|
|
@ -45,7 +45,7 @@ bool itemInstruction(const ItemCompletedSpy &spy, const QString &path, const Syn
|
|||
SyncJournalFileRecord dbRecord(FakeFolder &folder, const QString &path)
|
||||
{
|
||||
SyncJournalFileRecord record;
|
||||
folder.syncJournal().getFileRecord(path, &record);
|
||||
[[maybe_unused]] const auto result = folder.syncJournal().getFileRecord(path, &record);
|
||||
return record;
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,11 @@ void triggerDownload(FakeFolder &folder, const QByteArray &path)
|
|||
{
|
||||
auto &journal = folder.syncJournal();
|
||||
SyncJournalFileRecord record;
|
||||
journal.getFileRecord(path, &record);
|
||||
if (!record.isValid())
|
||||
if (!journal.getFileRecord(path, &record) || !record.isValid()) {
|
||||
return;
|
||||
}
|
||||
record._type = ItemTypeVirtualFileDownload;
|
||||
journal.setFileRecord(record);
|
||||
QVERIFY(journal.setFileRecord(record));
|
||||
journal.schedulePathForRemoteDiscovery(record._path);
|
||||
}
|
||||
|
||||
|
@ -65,11 +65,11 @@ void markForDehydration(FakeFolder &folder, const QByteArray &path)
|
|||
{
|
||||
auto &journal = folder.syncJournal();
|
||||
SyncJournalFileRecord record;
|
||||
journal.getFileRecord(path, &record);
|
||||
if (!record.isValid())
|
||||
if (!journal.getFileRecord(path, &record) || !record.isValid()) {
|
||||
return;
|
||||
}
|
||||
record._type = ItemTypeVirtualFileDehydration;
|
||||
journal.setFileRecord(record);
|
||||
QVERIFY(journal.setFileRecord(record));
|
||||
journal.schedulePathForRemoteDiscovery(record._path);
|
||||
}
|
||||
|
||||
|
@ -217,8 +217,8 @@ private slots:
|
|||
QCOMPARE(dbRecord(fakeFolder, "A/a3")._fileSize, 33);
|
||||
cleanup();
|
||||
|
||||
fakeFolder.syncEngine().journal()->deleteFileRecord("A/a2");
|
||||
fakeFolder.syncEngine().journal()->deleteFileRecord("A/a3");
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->deleteFileRecord("A/a2"));
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->deleteFileRecord("A/a3"));
|
||||
fakeFolder.remoteModifier().remove("A/a3");
|
||||
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::FilesystemOnly);
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
@ -436,7 +436,7 @@ private slots:
|
|||
|
||||
auto cleanup = [&]() {
|
||||
completeSpy.clear();
|
||||
fakeFolder.syncJournal().wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncJournal().wipeErrorBlacklist() != -1);
|
||||
};
|
||||
cleanup();
|
||||
|
||||
|
@ -708,8 +708,7 @@ private slots:
|
|||
};
|
||||
auto hasDehydratedDbEntries = [&](const QString &path) {
|
||||
SyncJournalFileRecord rec;
|
||||
fakeFolder.syncJournal().getFileRecord(path, &rec);
|
||||
return rec.isValid() && rec._type == ItemTypeVirtualFile;
|
||||
return fakeFolder.syncJournal().getFileRecord(path, &rec) && rec.isValid() && rec._type == ItemTypeVirtualFile;
|
||||
};
|
||||
|
||||
QVERIFY(isDehydrated("A/a1"));
|
||||
|
|
|
@ -48,21 +48,21 @@ private slots:
|
|||
QCOMPARE(uploadInfo._errorCount, 1);
|
||||
QCOMPARE(uploadInfo._transferid, 1U);
|
||||
|
||||
fakeFolder.syncEngine().journal()->wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->wipeErrorBlacklist());
|
||||
QVERIFY(!fakeFolder.syncOnce());
|
||||
|
||||
uploadInfo = fakeFolder.syncEngine().journal()->getUploadInfo("A/a0");
|
||||
QCOMPARE(uploadInfo._errorCount, 2);
|
||||
QCOMPARE(uploadInfo._transferid, 1U);
|
||||
|
||||
fakeFolder.syncEngine().journal()->wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->wipeErrorBlacklist());
|
||||
QVERIFY(!fakeFolder.syncOnce());
|
||||
|
||||
uploadInfo = fakeFolder.syncEngine().journal()->getUploadInfo("A/a0");
|
||||
QCOMPARE(uploadInfo._errorCount, 3);
|
||||
QCOMPARE(uploadInfo._transferid, 1U);
|
||||
|
||||
fakeFolder.syncEngine().journal()->wipeErrorBlacklist();
|
||||
QVERIFY(fakeFolder.syncEngine().journal()->wipeErrorBlacklist());
|
||||
QVERIFY(!fakeFolder.syncOnce());
|
||||
|
||||
uploadInfo = fakeFolder.syncEngine().journal()->getUploadInfo("A/a0");
|
||||
|
|
Loading…
Reference in a new issue