Test: Add unit test for PSU plug out and in
Split the function into two, one for handling the sdbus::message, the
other for handling the changed properties, so that it's easier to write
unit test cases.
Added the test cases:
* On a system with a PSU present, remove the PSU;
* On a system without PSU, plug the PSU in;
* On a system with a PSU, remove the PSU and add it back, while the
propertiesChanged callback is invoked with both Present and Version
properties.
* On a system with two PSUs with same version, remove them one-by-one,
and add back one-by-one, while PSU1 has a different version.
Tested: Verify ItemUpdater correctly handles the above cases:
* Remove the activation and version object if PSU is removed;
* Create activation and version object if PSU is added;
* When there are two PSUs with same version, removing one only
update the associations, removing the other shall result in
the objects to be removed;
Adding one back will create the objects, and adding the other
one with different version will create new objects.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I14c7ae9f03ec91bb1c85bb5a18d69f20dc1efd53
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index eeacdf8..f6fefff 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -91,12 +91,24 @@
*/
void createActivation(sdbusplus::message::message& msg);
+ using Properties =
+ std::map<std::string, utils::UtilsInterface::PropertyType>;
+
/** @brief Callback function for PSU inventory match.
* @details Update an Activation D-Bus object for PSU inventory.
*
* @param[in] msg - Data associated with subscribed signal
*/
- void onPsuInventoryChanged(sdbusplus::message::message& msg);
+ void onPsuInventoryChangedMsg(sdbusplus::message::message& msg);
+
+ /** @brief Callback function for PSU inventory match.
+ * @details Update an Activation D-Bus object for PSU inventory.
+ *
+ * @param[in] psuPath - The PSU inventory path
+ * @param[in] properties - The updated properties
+ */
+ void onPsuInventoryChanged(const std::string& psuPath,
+ const Properties& properties);
/** @brief Create Activation object */
std::unique_ptr<Activation> createActivationObject(