unit-test: Introduce unit tests to phosphor-objmgr
Move a function to make more testable and add a test case for it
Testing: Verified 100% test coverage in processing.cpp
Change-Id: I0a888009cfeb57bbc8ad295681bea00b79f2a23d
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/src/main.cpp b/src/main.cpp
index 7df7aa3..5870aea 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,3 +1,4 @@
+#include "processing.hpp"
#include "src/argument.hpp"
#include <tinyxml2.h>
@@ -85,26 +86,6 @@
};
};
-bool get_well_known(
- boost::container::flat_map<std::string, std::string>& owners,
- const std::string& request, std::string& well_known)
-{
- // If it's already a well known name, just return
- if (!boost::starts_with(request, ":"))
- {
- well_known = request;
- return true;
- }
-
- auto it = owners.find(request);
- if (it == owners.end())
- {
- return false;
- }
- well_known = it->second;
- return true;
-}
-
void update_owners(sdbusplus::asio::connection* conn,
boost::container::flat_map<std::string, std::string>& owners,
const std::string& new_object)
@@ -882,7 +863,7 @@
interfaces_added;
message.read(obj_path, interfaces_added);
std::string well_known;
- if (!get_well_known(name_owners, message.get_sender(), well_known))
+ if (!getWellKnown(name_owners, message.get_sender(), well_known))
{
return; // only introspect well-known
}
@@ -986,7 +967,7 @@
}
std::string sender;
- if (!get_well_known(name_owners, message.get_sender(), sender))
+ if (!getWellKnown(name_owners, message.get_sender(), sender))
{
return;
}
@@ -1043,8 +1024,8 @@
std::vector<Association>>(findAssociations->second);
std::string well_known;
- if (!get_well_known(name_owners, message.get_sender(),
- well_known))
+ if (!getWellKnown(name_owners, message.get_sender(),
+ well_known))
{
return;
}