Add unit test for item_udpater
To test item_updater easier, mocking utils is necessary.
So add a UtilsInterface to make the mocking eaiser.
Due to the fact that there is templated member functions that could not
be virtual, adding an extra "Impl" virtual function makes it possible to
simulates the mock of templated functions.
See
https://stackoverflow.com/questions/7968023/c-virtual-template-method
for details.
However, using std::any in with googlemock has an issue on GCC9, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415
for details.
So this commit uses std::experimental::any as a workaround.
With the mocked utils, it's easy to test item_updater in different
cases.
This commit adds the test cases for creating PSU objects, when:
* There is no PSU present
* There is one PSU present
* There are two PSUs present with the same version;
* There are two PSUs present with different versions.
Tested: Verify the unit tests passes.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I5d74ab26b344c5c40bc141f97b8aca42e74ee88e
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index 7bd9f66..eeacdf8 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -12,6 +12,8 @@
#include <xyz/openbmc_project/Association/Definitions/server.hpp>
#include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
+class TestItemUpdater;
+
namespace phosphor
{
namespace software
@@ -31,6 +33,8 @@
*/
class ItemUpdater : public ItemUpdaterInherit
{
+ friend class ::TestItemUpdater;
+
public:
/** @brief Constructs ItemUpdater
*