Skip to content

Commit

Permalink
Unit tests for the type change.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Dec 13, 2023
1 parent ed2ad42 commit 4672acb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/testsynccfapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4672acb

Please sign in to comment.