blob: 17d5c11712d66282fd1b412885260f1d1fef1d5e [file] [log] [blame]
Jason Ling84bff8b2020-11-06 13:45:09 -08001#include "create_action_map.hpp"
Patrick Venture1cde5f92018-11-07 08:26:47 -08002#include "data_mock.hpp"
Patrick Venturedf848ee2018-11-06 15:44:00 -08003#include "firmware_handler.hpp"
Patrick Venture84778b82019-06-26 20:11:09 -07004#include "flags.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08005#include "image_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07006#include "util.hpp"
Patrick Venturedf848ee2018-11-06 15:44:00 -08007
Patrick Venturedf848ee2018-11-06 15:44:00 -08008#include <vector>
9
10#include <gtest/gtest.h>
11
Patrick Venture1d5a31c2019-05-20 11:38:22 -070012namespace ipmi_flash
Patrick Venturedf848ee2018-11-06 15:44:00 -080013{
14TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk)
15{
Patrick Venturedf848ee2018-11-06 15:44:00 -080016 struct ListItem
17 {
18 std::string name;
19 bool expected;
20 };
21
22 std::vector<ListItem> items = {
23 {"asdf", true}, {"nope", false}, {"123123", false}, {"bcdf", true}};
24
Patrick Venturea78e39f2018-11-06 18:37:06 -080025 ImageHandlerMock imageMock;
26
Patrick Ventured4e20de2019-07-18 12:48:05 -070027 std::vector<HandlerPack> blobs;
Patrick Venturec6ba8ff2020-09-23 12:42:57 -070028 blobs.emplace_back(hashBlobId, std::make_unique<ImageHandlerMock>());
29 blobs.emplace_back("asdf", std::make_unique<ImageHandlerMock>());
30 blobs.emplace_back("bcdf", std::make_unique<ImageHandlerMock>());
Patrick Ventured4e20de2019-07-18 12:48:05 -070031
Patrick Venture4934daa2020-09-22 16:37:44 -070032 std::vector<DataHandlerPack> data;
33 data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
Patrick Venturea78e39f2018-11-06 18:37:06 -080034
Patrick Venture4eb55952018-11-16 15:36:24 -080035 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Ventureda4d4a42020-09-28 11:41:05 -070036 std::move(blobs), std::move(data), CreateActionMap("asdf"));
Patrick Venturedf848ee2018-11-06 15:44:00 -080037
38 for (const auto& item : items)
39 {
40 EXPECT_EQ(item.expected, handler->canHandleBlob(item.name));
41 }
42}
Patrick Venture1d5a31c2019-05-20 11:38:22 -070043} // namespace ipmi_flash