1 #include "handler_config.hpp" 2 #include "image_mock.hpp" 3 #include "triggerable_mock.hpp" 4 #include "version_handler.hpp" 5 6 #include <memory> 7 #include <string> 8 #include <utility> 9 10 namespace ipmi_flash 11 { 12 13 auto createMockVersionConfig(const std::string& id, 14 ImageHandlerMock** im = nullptr, 15 TriggerMock** tm = nullptr) 16 { 17 HandlerConfig<VersionBlobHandler::ActionPack> ret; 18 ret.blobId = id; 19 auto handler = std::make_unique<testing::StrictMock<ImageHandlerMock>>(); 20 if (im != nullptr) 21 { 22 *im = handler.get(); 23 } 24 ret.handler = std::move(handler); 25 ret.actions = std::make_unique<VersionBlobHandler::ActionPack>(); 26 auto trigger = std::make_unique<testing::StrictMock<TriggerMock>>(); 27 if (tm != nullptr) 28 { 29 *tm = trigger.get(); 30 } 31 ret.actions->onOpen = std::move(trigger); 32 return ret; 33 } 34 35 template <typename C, typename Im = std::map<std::string, ImageHandlerMock*>, 36 typename Tm = std::map<std::string, TriggerMock*>> 37 auto createMockVersionConfigs(const C& ids, Im* im = nullptr, Tm* tm = nullptr) 38 { 39 std::vector<HandlerConfig<VersionBlobHandler::ActionPack>> ret; 40 for (const auto& id : ids) 41 { 42 ret.push_back( 43 createMockVersionConfig(id, im == nullptr ? nullptr : &(*im)[id], 44 tm == nullptr ? nullptr : &(*tm)[id])); 45 } 46 return ret; 47 } 48 49 } // namespace ipmi_flash 50