Skip to content

Commit b87a569

Browse files
committed
Fix unit test now that we really abort the sync
1 parent 2b95e9f commit b87a569

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/testchunkingng.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,10 @@ private slots:
330330
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
331331
}
332332

333-
// Check what happens when we abort during the final MOVE and the
334-
// the final MOVE is short enough for the abort-delay to help
333+
// Check what happens when we abort during the final MOVE.
334+
// The move succeeds on the server but as we abort it we won't realize in time.
335+
// This means that the current sync fails, as it is aborted, but the MOVE was still performed on the server.
336+
// Resulting in the local state being the same as the remote state.
335337
void testLateAbortRecoverable()
336338
{
337339
FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
@@ -344,18 +346,31 @@ private slots:
344346
fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *) -> QNetworkReply * {
345347
if (request.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray() == "MOVE") {
346348
QTimer::singleShot(50ms, &parent, [&]() { fakeFolder.syncEngine().abort(); });
349+
// while the response is delayed, the move is performed in the constructor, thus it happens immediately
347350
return new DelayedReply<FakeChunkMoveReply>(responseDelay, fakeFolder.uploadState(), fakeFolder.remoteModifier(), op, request, &parent);
348351
}
349352
return nullptr;
350353
});
351354

352355
// Test 1: NEW file aborted
353356
fakeFolder.localModifier().insert(QStringLiteral("A/a0"), size);
357+
// the sync will be aborted and thus fail
358+
QVERIFY(!fakeFolder.applyLocalModificationsAndSync());
359+
// the move was still performed
360+
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
361+
362+
// update the meta data after the aborted sync
354363
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
355364
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
356365

357366
// Test 2: modified file upload aborted
358367
fakeFolder.localModifier().appendByte(QStringLiteral("A/a0"));
368+
// the sync will be aborted and thus fail
369+
QVERIFY(!fakeFolder.applyLocalModificationsAndSync());
370+
// the move was still performed
371+
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
372+
373+
// update the meta data after the aborted sync
359374
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
360375
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
361376
}

0 commit comments

Comments
 (0)