diff --git a/test/testsynccfapi.cpp b/test/testsynccfapi.cpp index b67e19422f02..dd6fd80eb1fe 100644 --- a/test/testsynccfapi.cpp +++ b/test/testsynccfapi.cpp @@ -1384,6 +1384,32 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QVERIFY(itemInstruction(completeSpy, "A", CSYNC_INSTRUCTION_NONE)); } + + void testRemoteTypeChangeExistingLocalMustGetRemoved() + { + FakeFolder fakeFolder{FileInfo{}}; + setupVfs(fakeFolder); + + // test file change to directory on remote + fakeFolder.remoteModifier().mkdir("a"); + fakeFolder.remoteModifier().insert("a/TESTFILE"); + QVERIFY(fakeFolder.syncOnce()); + + fakeFolder.remoteModifier().remove("a/TESTFILE"); + fakeFolder.remoteModifier().mkdir("a/TESTFILE"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + + + // test directory change to file on remote + fakeFolder.remoteModifier().mkdir("a/TESTDIR"); + QVERIFY(fakeFolder.syncOnce()); + + fakeFolder.remoteModifier().remove("a/TESTDIR"); + fakeFolder.remoteModifier().insert("a/TESTDIR"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + } }; QTEST_GUILESS_MAIN(TestSyncCfApi) diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp index 10fcea8e63c3..fa3e19f1318b 100644 --- a/test/testsyncengine.cpp +++ b/test/testsyncengine.cpp @@ -1726,6 +1726,30 @@ private slots: QVERIFY(itemDidCompleteSuccessfully(completeSpy, "A/abcdęfg.txt")); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + + void testRemoteTypeChangeExistingLocalMustGetRemoved() + { + FakeFolder fakeFolder{FileInfo{}}; + + // test file change to directory on remote + fakeFolder.remoteModifier().mkdir("a"); + fakeFolder.remoteModifier().insert("a/TESTFILE"); + QVERIFY(fakeFolder.syncOnce()); + + fakeFolder.remoteModifier().remove("a/TESTFILE"); + fakeFolder.remoteModifier().mkdir("a/TESTFILE"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + + // test directory change to file on remote + fakeFolder.remoteModifier().mkdir("a/TESTDIR"); + QVERIFY(fakeFolder.syncOnce()); + + fakeFolder.remoteModifier().remove("a/TESTDIR"); + fakeFolder.remoteModifier().insert("a/TESTDIR"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + } }; QTEST_GUILESS_MAIN(TestSyncEngine)