1 #include "utils.hpp" 2 3 #include <gmock/gmock.h> 4 5 namespace utils 6 { 7 8 class MockedUtils : public UtilsInterface 9 { 10 public: 11 ~MockedUtils() override = default; 12 13 MOCK_CONST_METHOD1(getPSUInventoryPath, 14 std::vector<std::string>(sdbusplus::bus_t& bus)); 15 16 MOCK_CONST_METHOD3(getService, 17 std::string(sdbusplus::bus_t& bus, const char* path, 18 const char* interface)); 19 20 MOCK_CONST_METHOD3(getServices, 21 std::vector<std::string>(sdbusplus::bus_t& bus, 22 const char* path, 23 const char* interface)); 24 25 MOCK_CONST_METHOD1(getVersionId, std::string(const std::string& version)); 26 27 MOCK_CONST_METHOD1(getVersion, 28 std::string(const std::string& psuInventoryPath)); 29 30 MOCK_CONST_METHOD1(getLatestVersion, 31 std::string(const std::set<std::string>& versions)); 32 33 MOCK_CONST_METHOD2(isAssociated, bool(const std::string& psuInventoryPath, 34 const AssociationList& assocs)); 35 36 MOCK_CONST_METHOD5(getPropertyImpl, 37 any(sdbusplus::bus_t& bus, const char* service, 38 const char* path, const char* interface, 39 const char* propertyName)); 40 }; 41 42 static std::unique_ptr<MockedUtils> utils; 43 inline const UtilsInterface& getUtils() 44 { 45 if (!utils) 46 { 47 utils = std::make_unique<MockedUtils>(); 48 } 49 return *utils; 50 } 51 52 inline void freeUtils() 53 { 54 utils.reset(); 55 } 56 57 } // namespace utils 58