// Copyright 2021 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "handler_config.hpp" #include "image_mock.hpp" #include "log_handler.hpp" #include "triggerable_mock.hpp" #include #include #include namespace ipmi_flash { auto createMockLogConfig(const std::string& id, ImageHandlerMock** im = nullptr, TriggerMock** tm = nullptr) { HandlerConfig ret; ret.blobId = id; auto handler = std::make_unique>(); if (im != nullptr) { *im = handler.get(); } ret.handler = std::move(handler); ret.actions = std::make_unique(); auto trigger = std::make_unique>(); if (tm != nullptr) { *tm = trigger.get(); } ret.actions->onOpen = std::move(trigger); return ret; } template , typename Tm = std::map> auto createMockLogConfigs(const C& ids, Im* im = nullptr, Tm* tm = nullptr) { std::vector> ret; for (const auto& id : ids) { ret.push_back( createMockLogConfig(id, im == nullptr ? nullptr : &(*im)[id], tm == nullptr ? nullptr : &(*tm)[id])); } return ret; } } // namespace ipmi_flash