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 17, 2023
1 parent 8f42454 commit 887a319
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,42 @@ private slots:

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


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

FakeFolder fakeFolder(FileInfo::A12_B12_C12_S12(), vfsMode, filesAreDehydrated);
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());

// during an upload of B/newFile an error occurs that aborts all delete jobs
fakeFolder.localModifier().insert(QStringLiteral("B/newFile"));
fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *) -> QNetworkReply * {
if (op == QNetworkAccessManager::PutOperation) {
return new FakeErrorReply(op, request, this, 507);
}
return nullptr;
});

// this will go through
fakeFolder.remoteModifier().insert(QStringLiteral("C/newRemoteFile"));

// those will fail https://github.com/owncloud/client/issues/9311
fakeFolder.remoteModifier().remove(QStringLiteral("A"));
fakeFolder.remoteModifier().remove(QStringLiteral("S"));

QVERIFY(!fakeFolder.applyLocalModificationsAndSync());

// the download succeeded
QVERIFY(fakeFolder.currentLocalState().find(QStringLiteral("C/newRemoteFile")));

// the deletes happened as they are independent of the error in B
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("A")));
QVERIFY(!fakeFolder.currentLocalState().find(QStringLiteral("S")));
}
};

QTEST_GUILESS_MAIN(TestSyncEngine)
Expand Down

0 comments on commit 887a319

Please sign in to comment.