diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2020-02-06 12:47:59 +0300 |
---|---|---|
committer | Olivier Goffart <olivier@woboq.com> | 2020-02-10 17:15:15 +0300 |
commit | aaa51e203d80c96230cc83631d303276456a3d20 (patch) | |
tree | 487cd1116ae2e55f9775040f08e968cc32bc4b44 /test | |
parent | 2bd5e165f80412672e4b0df71618b54c90a3c1a2 (diff) |
Tests: add a couple of move tests
This was an attempt to reproduce #7722, but this actually does not
reproduce it
Diffstat (limited to 'test')
-rw-r--r-- | test/testsyncmove.cpp | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 4122b91e0..51c60afda 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -287,40 +287,46 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - int nGET = 0; - fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &, QIODevice *) { - if (op == QNetworkAccessManager::GetOperation) - ++nGET; - return nullptr; - }); + OperationCounter counter; + fakeFolder.setServerOverride(counter.functor()); // Try a remote file move remote.rename("A/a1", "A/W/a1m"); remote.rename(prefix + "/A/a1", prefix + "/A/W/a1m"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 0); + QCOMPARE(counter.nGET, 0); // And a remote directory move remote.rename("A/W", "A/Q/W"); remote.rename(prefix + "/A/W", prefix + "/A/Q/W"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 0); + QCOMPARE(counter.nGET, 0); // Partial file removal (in practice, A/a2 may be moved to O/a2, but we don't care) remote.rename(prefix + "/A/a2", prefix + "/a2"); remote.remove("A/a2"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 0); + QCOMPARE(counter.nGET, 0); // Local change plus remote move at the same time fakeFolder.localModifier().appendByte(prefix + "/a2"); remote.rename(prefix + "/a2", prefix + "/a3"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 1); + QCOMPARE(counter.nGET, 1); + counter.reset(); + + // remove localy, and remote move at the same time + fakeFolder.localModifier().remove("A/Q/W/a1m"); + remote.rename("A/Q/W/a1m", "A/Q/W/a1p"); + remote.rename(prefix + "/A/Q/W/a1m", prefix + "/A/Q/W/a1p"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + QCOMPARE(counter.nGET, 1); + counter.reset(); } void testMovePropagation() @@ -807,6 +813,35 @@ private slots: QCOMPARE(counter.nMOVE, 2); } + void moveFileToDifferentFolderOnBothSides() + { + FakeFolder fakeFolder { FileInfo::A12_B12_C12_S12() }; + OperationCounter counter; + fakeFolder.setServerOverride(counter.functor()); + + // Test that moving a file within to different folder on both side does the right thing. + + fakeFolder.remoteModifier().rename("B/b1", "A/b1"); + fakeFolder.localModifier().rename("B/b1", "C/b1"); + + fakeFolder.localModifier().rename("B/b2", "A/b2"); + fakeFolder.remoteModifier().rename("B/b2", "C/b2"); + + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentRemoteState(), fakeFolder.currentRemoteState()); + QVERIFY(fakeFolder.currentRemoteState().find("A/b1")); + QVERIFY(fakeFolder.currentRemoteState().find("C/b1")); + QVERIFY(fakeFolder.currentRemoteState().find("A/b2")); + QVERIFY(fakeFolder.currentRemoteState().find("C/b2")); + qDebug() << counter.nMOVE << counter.nDELETE << counter.nGET << counter.nPUT; + QCOMPARE(counter.nMOVE, 0); // Unfortunately, we can't really make a move in this case + QCOMPARE(counter.nGET, 2); + QCOMPARE(counter.nPUT, 2); + QCOMPARE(counter.nDELETE, 0); + counter.reset(); + + } + // Test that deletes don't run before renames void testRenameParallelism() { |