Skip to content

Commit

Permalink
Merge pull request #5273 from nextcloud/bugfix/testsyncengine-fix-loc…
Browse files Browse the repository at this point in the history
…alstate-destroyed-failure

Fix SyncEngineTest failure when localstate is destroyed.
  • Loading branch information
mgallien authored Dec 15, 2022
2 parents d48baba + 089b677 commit 051db4a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,29 +1256,33 @@ private slots:

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem);
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
auto localState = fakeFolder.currentLocalState();
QCOMPARE(localState, fakeFolder.currentRemoteState());
QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.currentRemoteState()));
const auto fileFirstSync = fakeFolder.currentLocalState().find(testFile);
const auto fileFirstSync = localState.find(testFile);

QVERIFY(fileFirstSync);
QCOMPARE(fileFirstSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME - 2);

fakeFolder.remoteModifier().setModTimeKeepEtag(testFile, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME - 1));

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly);
QVERIFY(fakeFolder.syncOnce());
localState = fakeFolder.currentLocalState();
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.currentRemoteState()));
const auto fileSecondSync = fakeFolder.currentLocalState().find(testFile);
const auto fileSecondSync = localState.find(testFile);
QVERIFY(fileSecondSync);
QCOMPARE(fileSecondSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME - 1);

fakeFolder.remoteModifier().setModTime(testFile, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly);
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
localState = fakeFolder.currentLocalState();
QCOMPARE(localState, fakeFolder.currentRemoteState());
QCOMPARE(printDbData(fakeFolder.dbState()), printDbData(fakeFolder.currentRemoteState()));
const auto fileThirdSync = fakeFolder.currentLocalState().find(testFile);
const auto fileThirdSync = localState.find(testFile);
QVERIFY(fileThirdSync);
QCOMPARE(fileThirdSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME);
}
Expand Down

0 comments on commit 051db4a

Please sign in to comment.