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() = default;
12 MockedUtils(const MockedUtils&) = delete;
13 MockedUtils& operator=(const MockedUtils&) = delete;
14 MockedUtils(MockedUtils&&) = delete;
15 MockedUtils& operator=(MockedUtils&&) = delete;
16
17 ~MockedUtils() override = default;
18
19 MOCK_CONST_METHOD1(getPSUInventoryPath,
20 std::vector<std::string>(sdbusplus::bus_t& bus));
21
22 MOCK_CONST_METHOD3(getService,
23 std::string(sdbusplus::bus_t& bus, const char* path,
24 const char* interface));
25
26 MOCK_CONST_METHOD3(getServices,
27 std::vector<std::string>(sdbusplus::bus_t& bus,
28 const char* path,
29 const char* interface));
30
31 MOCK_CONST_METHOD1(getVersionId, std::string(const std::string& version));
32
33 MOCK_CONST_METHOD1(getVersion,
34 std::string(const std::string& psuInventoryPath));
35
36 MOCK_CONST_METHOD1(getLatestVersion,
37 std::string(const std::set<std::string>& versions));
38
39 MOCK_CONST_METHOD2(isAssociated, bool(const std::string& psuInventoryPath,
40 const AssociationList& assocs));
41
42 MOCK_CONST_METHOD5(getPropertyImpl,
43 any(sdbusplus::bus_t& bus, const char* service,
44 const char* path, const char* interface,
45 const char* propertyName));
46 };
47
48 static std::unique_ptr<MockedUtils> utils;
getUtils()49 inline const UtilsInterface& getUtils()
50 {
51 if (!utils)
52 {
53 utils = std::make_unique<MockedUtils>();
54 }
55 return *utils;
56 }
57
freeUtils()58 inline void freeUtils()
59 {
60 utils.reset();
61 }
62
63 } // namespace utils
64