Skip to content

Commit

Permalink
Result modifications, action bug fixes, and functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoungbq committed Apr 30, 2024
1 parent 3fdb303 commit 49c56ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
29 changes: 15 additions & 14 deletions src/Plugins/SimplnxCore/test/RenameDataObjectTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ TEST_CASE("SimplnxCore::RenameDataAction(Valid Overwrite)", "[SimplnxCore][Renam
auto preflightResult = filter.preflight(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions);

bool warningFound = false;
for(const auto& warning : preflightResult.outputActions.warnings())
{
if(warning.code == -6602)
{
warningFound = true;
}
}
REQUIRE(warningFound);
// There is a warning clause, but under current implementation it won't be reached
// bool warningFound = false;
// for(const auto& warning : preflightResult.outputActions.warnings())
// {
// if(warning.code == -6602)
// {
// warningFound = true;
// }
// }
// REQUIRE(warningFound);

auto result = filter.execute(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(result.result);
Expand Down Expand Up @@ -135,18 +136,18 @@ TEST_CASE("SimplnxCore::RenameDataAction(InValid Overwrite)", "[SimplnxCore][Ren
args.insert(RenameDataObject::k_SourceDataObjectPath_Key, std::make_any<DataPath>(k_DataPath));

auto preflightResult = filter.preflight(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_INVALID(preflightResult.outputActions);
SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions);

auto result = filter.execute(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_INVALID(result.result);

bool errorFound = false;
for(const auto& error : preflightResult.outputActions.errors())
for(const auto& error : result.result.errors())
{
if(error.code == -6601)
{
errorFound = true;
}
}
REQUIRE(errorFound);

auto result = filter.execute(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_INVALID(result.result);
}
2 changes: 1 addition & 1 deletion src/simplnx/Common/Result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ inline Result<T> MergeResults(Result<T> first, Result<T> second)
}
}

Result<T> result = errors.empty() ? Result<T>{} : Result<T>{nonstd::make_unexpected(std::move(errors))};
Result<T> result = errors.empty() ? Result<T>{} : Result<T>{{nonstd::make_unexpected(std::move(errors))}};

result.m_Warnings.reserve(first.warnings().size() + second.warnings().size());
for(auto&& warning : first.warnings())
Expand Down
12 changes: 8 additions & 4 deletions src/simplnx/Filter/Actions/RenameDataAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ Result<> TerminateNodesRecursively(DataStructure& dataStructure, DataObject::IdT
}
}

auto childIds = dataStructure.getDataRefAs<BaseGroup>(id).GetChildrenIds();
if(!childIds.empty())
auto* baseGroup = dataStructure.getDataAs<BaseGroup>(id);
if(baseGroup != nullptr)
{
for(const auto& childId : childIds)
auto childIds = baseGroup->GetChildrenIds();
if(!childIds.empty())
{
result = MergeResults(result, std::move(TerminateNodesRecursively(dataStructure, childId, mode, checkDependence)));
for(const auto& childId : childIds)
{
result = MergeResults(result, std::move(TerminateNodesRecursively(dataStructure, childId, mode, checkDependence)));
}
}
}

Expand Down

0 comments on commit 49c56ef

Please sign in to comment.