From 28aae8d5142d571a5ab816fd21a730e5fe993b85 Mon Sep 17 00:00:00 2001 From: Luc Guyot Date: Mon, 18 Nov 2024 16:47:05 +0100 Subject: [PATCH] =?UTF-8?q?Addresses=20Cl=C3=A9ment's=20comment:=20adds=20?= =?UTF-8?q?unit=20tests=20for=20the=20case=20where=20Shared=20is=20a=20cor?= =?UTF-8?q?responding=20parent=20node?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/testexecutorworker.cpp | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test/libsyncengine/propagation/executor/testexecutorworker.cpp b/test/libsyncengine/propagation/executor/testexecutorworker.cpp index 1246a965f..ee3d05a5f 100644 --- a/test/libsyncengine/propagation/executor/testexecutorworker.cpp +++ b/test/libsyncengine/propagation/executor/testexecutorworker.cpp @@ -244,7 +244,7 @@ void TestExecutorWorker::testIsValidDestination() { const auto executorWorkerMock = std::shared_ptr(new ExecutorWorkerMock(_syncPal, "Executor", "EXEC")); - // False if the item is created on the local replica is not at the root of the synchronisation folder and has no + // False if the item created on the local replica is not at the root of the synchronisation folder and has no // corresponding parent node. { SyncOpPtr op = generateSyncOperationWithNestedNodes(1, Str("test_file.txt"), OperationType::Create, NodeType::File); @@ -255,7 +255,7 @@ void TestExecutorWorker::testIsValidDestination() { const auto root = _syncPal->updateTree(ReplicaSide::Remote)->rootNode(); - // False if the item is created on the local replica is not at the root of the synchronisation folder and has a + // False if the item created on the local replica is not at the root of the synchronisation folder and has a // corresponding parent node with no id. { const auto correspondingParentNode = std::make_shared( @@ -273,7 +273,7 @@ void TestExecutorWorker::testIsValidDestination() { 666, ReplicaSide::Remote, Utility::commonDocumentsFolderName(), NodeType::Directory, OperationType::None, "common_docs_id", testhelpers::defaultTime, testhelpers::defaultTime, testhelpers::defaultFileSize, root); - // False if the item is created on the local replica is a file and has Common Documents as corresponding parent node. + // False if the item created on the local replica is a file and has Common Documents as corresponding parent node. { SyncOpPtr op = generateSyncOperationWithNestedNodes(1, Str("test_file.txt"), OperationType::Create, NodeType::File); op->setTargetSide(ReplicaSide::Remote); @@ -282,7 +282,7 @@ void TestExecutorWorker::testIsValidDestination() { CPPUNIT_ASSERT(!executorWorkerMock->isValidDestination(op)); } - // True if the item is created on the local replica is a directory and has Common Documents as corresponding parent node. + // True if the item created on the local replica is a directory and has Common Documents as corresponding parent node. { SyncOpPtr op = generateSyncOperationWithNestedNodes(1, Str("test_dir"), OperationType::Create, NodeType::Directory); op->setTargetSide(ReplicaSide::Remote); @@ -290,6 +290,26 @@ void TestExecutorWorker::testIsValidDestination() { {{op->affectedNode()->parentNode(), correspondingParentCommonDocsNode}}); CPPUNIT_ASSERT(executorWorkerMock->isValidDestination(op)); } + + const auto correspondingParentSharedNode = std::make_shared( + 777, ReplicaSide::Remote, Utility::sharedFolderName(), NodeType::Directory, OperationType::None, "shared_id", + testhelpers::defaultTime, testhelpers::defaultTime, testhelpers::defaultFileSize, root); + + // False if the item is created on the local replica is a file and has Shared as corresponding parent node. + { + SyncOpPtr op = generateSyncOperationWithNestedNodes(1, Str("test_file.txt"), OperationType::Create, NodeType::File); + op->setTargetSide(ReplicaSide::Remote); + executorWorkerMock->setCorrespondingNodeInOtherTree({{op->affectedNode()->parentNode(), correspondingParentSharedNode}}); + CPPUNIT_ASSERT(!executorWorkerMock->isValidDestination(op)); + } + + // False if the item created on the local replica is a directory and has Shared as corresponding parent node. + { + SyncOpPtr op = generateSyncOperationWithNestedNodes(1, Str("test_dir"), OperationType::Create, NodeType::Directory); + op->setTargetSide(ReplicaSide::Remote); + executorWorkerMock->setCorrespondingNodeInOtherTree({{op->affectedNode()->parentNode(), correspondingParentSharedNode}}); + CPPUNIT_ASSERT(!executorWorkerMock->isValidDestination(op)); + } } void TestExecutorWorker::testLogCorrespondingNodeErrorMsg() {