diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2019-02-04 13:00:59 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-04-05 15:05:32 +0000 |
commit | 67e5a420756d7ae96be91721138054be9d897a7b (patch) | |
tree | f5f2d92f1bb082866c36ef0fe8a5b668fc6c9058 | |
parent | 82815dac90179222879cc9c46e39799bf75ee829 (diff) | |
download | phosphor-objmgr-67e5a420756d7ae96be91721138054be9d897a7b.tar.gz phosphor-objmgr-67e5a420756d7ae96be91721138054be9d897a7b.zip |
unit-test: Add all required parameters to removeAssociation
Testing is easier when all required parameters are input (vs. global
references)
Change-Id: I0c6c45c79a6095eaa6d702150cc346ac4f8e0e0d
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
-rw-r--r-- | src/main.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index dea80f8..801d910 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,10 +36,11 @@ using Association = std::tuple<std::string, std::string, std::string>; static constexpr auto ifacePos = 0; static constexpr auto endpointsPos = 1; using Endpoints = std::vector<std::string>; -boost::container::flat_map< +using AssociationInterfaces = boost::container::flat_map< std::string, - std::tuple<std::shared_ptr<sdbusplus::asio::dbus_interface>, Endpoints>> - associationInterfaces; + std::tuple<std::shared_ptr<sdbusplus::asio::dbus_interface>, Endpoints>>; + +AssociationInterfaces associationInterfaces; // The associationOwners map contains information about creators of // associations, so that when a org.openbmc.Association interface is @@ -365,7 +366,9 @@ void associationChanged(sdbusplus::asio::object_server& objectServer, } void removeAssociation(const std::string& sourcePath, const std::string& owner, - sdbusplus::asio::object_server& server) + sdbusplus::asio::object_server& server, + AssociationOwnersType& assocOwners, + AssociationInterfaces& assocInterfaces) { // Use associationOwners to find the association paths and endpoints // that the passed in object path and service own. Remove all of @@ -377,8 +380,8 @@ void removeAssociation(const std::string& sourcePath, const std::string& owner, // association path itself. // Find the services that have associations for this object path - auto owners = associationOwners.find(sourcePath); - if (owners == associationOwners.end()) + auto owners = assocOwners.find(sourcePath); + if (owners == assocOwners.end()) { return; } @@ -394,8 +397,8 @@ void removeAssociation(const std::string& sourcePath, const std::string& owner, for (const auto& [assocPath, endpointsToRemove] : assocs->second) { // Get the association D-Bus object for this assocPath - auto target = associationInterfaces.find(assocPath); - if (target == associationInterfaces.end()) + auto target = assocInterfaces.find(assocPath); + if (target == assocInterfaces.end()) { continue; } @@ -796,7 +799,9 @@ int main(int argc, char** argv) if (assoc != ifaces->second.end()) { - removeAssociation(path_it->first, name, server); + removeAssociation(path_it->first, name, server, + associationOwners, + associationInterfaces); } } @@ -968,7 +973,8 @@ int main(int argc, char** argv) if (interface == ASSOCIATIONS_INTERFACE) { - removeAssociation(obj_path.str, sender, server); + removeAssociation(obj_path.str, sender, server, + associationOwners, associationInterfaces); } interface_set->second.erase(interface); |