SyncEngineTest: Fix test reliability

There was a rounding issue in the mtimes which sometimes resulted in an
off-by-one error. Caused by storing a full QDateTime in the FileInfo but
the mtime saved to the disk being truncated to seconds.
This commit is contained in:
Christian Kamm 2017-07-04 09:57:22 +02:00
parent 30095a0c3f
commit 0db095e02a

View file

@ -392,9 +392,7 @@ private slots:
*/
void testSyncFileItemProperties()
{
FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
auto initialMtime = fakeFolder.currentLocalState().find("A/a1")->lastModified;
auto initialMtime = QDateTime::currentDateTime().addDays(-7);
auto changedMtime = QDateTime::currentDateTime().addDays(-4);
auto changedMtime2 = QDateTime::currentDateTime().addDays(-3);
@ -403,6 +401,15 @@ private slots:
changedMtime.setMSecsSinceEpoch(changedMtime.toMSecsSinceEpoch() / 1000 * 1000);
changedMtime2.setMSecsSinceEpoch(changedMtime2.toMSecsSinceEpoch() / 1000 * 1000);
// Ensure the initial mtimes are as expected
auto initialFileInfo = FileInfo::A12_B12_C12_S12();
initialFileInfo.setModTime("A/a1", initialMtime);
initialFileInfo.setModTime("B/b1", initialMtime);
initialFileInfo.setModTime("C/c1", initialMtime);
FakeFolder fakeFolder{ initialFileInfo };
// upload a
fakeFolder.localModifier().appendByte("A/a1");
fakeFolder.localModifier().setModTime("A/a1", changedMtime);