1f77189f7SLei YU #include "utils.hpp"
2f77189f7SLei YU
3f77189f7SLei YU #include <gmock/gmock.h>
4f77189f7SLei YU
5f77189f7SLei YU namespace utils
6f77189f7SLei YU {
7f77189f7SLei YU
8f77189f7SLei YU class MockedUtils : public UtilsInterface
9f77189f7SLei YU {
10f77189f7SLei YU public:
11*66a54ad4SGeorge Liu MockedUtils() = default;
12*66a54ad4SGeorge Liu MockedUtils(const MockedUtils&) = delete;
13*66a54ad4SGeorge Liu MockedUtils& operator=(const MockedUtils&) = delete;
14*66a54ad4SGeorge Liu MockedUtils(MockedUtils&&) = delete;
15*66a54ad4SGeorge Liu MockedUtils& operator=(MockedUtils&&) = delete;
16*66a54ad4SGeorge Liu
17047d9944SGeorge Liu ~MockedUtils() override = default;
18f77189f7SLei YU
19f77189f7SLei YU MOCK_CONST_METHOD1(getPSUInventoryPath,
20374fae56SPatrick Williams std::vector<std::string>(sdbusplus::bus_t& bus));
21f77189f7SLei YU
22f77189f7SLei YU MOCK_CONST_METHOD3(getService,
23374fae56SPatrick Williams std::string(sdbusplus::bus_t& bus, const char* path,
24f77189f7SLei YU const char* interface));
25f77189f7SLei YU
26d0bbfa9eSLei YU MOCK_CONST_METHOD3(getServices,
27374fae56SPatrick Williams std::vector<std::string>(sdbusplus::bus_t& bus,
28d0bbfa9eSLei YU const char* path,
29d0bbfa9eSLei YU const char* interface));
30d0bbfa9eSLei YU
31f77189f7SLei YU MOCK_CONST_METHOD1(getVersionId, std::string(const std::string& version));
32f77189f7SLei YU
335f3584d4SLei YU MOCK_CONST_METHOD1(getVersion,
345f3584d4SLei YU std::string(const std::string& psuInventoryPath));
355f3584d4SLei YU
366520748dSLei YU MOCK_CONST_METHOD1(getLatestVersion,
376520748dSLei YU std::string(const std::set<std::string>& versions));
386520748dSLei YU
394b9ac392SLei YU MOCK_CONST_METHOD2(isAssociated, bool(const std::string& psuInventoryPath,
404b9ac392SLei YU const AssociationList& assocs));
414b9ac392SLei YU
42f77189f7SLei YU MOCK_CONST_METHOD5(getPropertyImpl,
43374fae56SPatrick Williams any(sdbusplus::bus_t& bus, const char* service,
44f77189f7SLei YU const char* path, const char* interface,
45f77189f7SLei YU const char* propertyName));
46f77189f7SLei YU };
47f77189f7SLei YU
48c09155bbSLei YU static std::unique_ptr<MockedUtils> utils;
getUtils()49ff83c2a0SLei YU inline const UtilsInterface& getUtils()
50f77189f7SLei YU {
51c09155bbSLei YU if (!utils)
52c09155bbSLei YU {
53c09155bbSLei YU utils = std::make_unique<MockedUtils>();
54c09155bbSLei YU }
55c09155bbSLei YU return *utils;
56c09155bbSLei YU }
57c09155bbSLei YU
freeUtils()58c09155bbSLei YU inline void freeUtils()
59c09155bbSLei YU {
60c09155bbSLei YU utils.reset();
61f77189f7SLei YU }
62f77189f7SLei YU
63f77189f7SLei YU } // namespace utils
64