Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 1 | #include "data_mock.hpp" |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 2 | #include "firmware_handler.hpp" |
Patrick Venture | 84778b8 | 2019-06-26 20:11:09 -0700 | [diff] [blame] | 3 | #include "flags.hpp" |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 4 | #include "image_mock.hpp" |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 5 | #include "triggerable_mock.hpp" |
Patrick Venture | 7dad86f | 2019-05-17 08:52:20 -0700 | [diff] [blame] | 6 | #include "util.hpp" |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 7 | |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
| 10 | #include <gtest/gtest.h> |
| 11 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 12 | namespace ipmi_flash |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 13 | { |
| 14 | TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk) |
| 15 | { |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 16 | 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 Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 25 | ImageHandlerMock imageMock; |
| 26 | |
Patrick Venture | d4e20de | 2019-07-18 12:48:05 -0700 | [diff] [blame] | 27 | std::vector<HandlerPack> blobs; |
| 28 | blobs.push_back(std::move( |
| 29 | HandlerPack(hashBlobId, std::make_unique<ImageHandlerMock>()))); |
| 30 | blobs.push_back( |
| 31 | std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>()))); |
| 32 | blobs.push_back( |
| 33 | std::move(HandlerPack("bcdf", std::make_unique<ImageHandlerMock>()))); |
| 34 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 35 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 84778b8 | 2019-06-26 20:11:09 -0700 | [diff] [blame] | 36 | {FirmwareFlags::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 37 | }; |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 38 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 39 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
Patrick Venture | 7b78343 | 2020-09-22 15:55:08 -0700 | [diff] [blame^] | 40 | std::move(blobs), std::move(data), std::move(CreateActionMap("asdf"))); |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 41 | |
| 42 | for (const auto& item : items) |
| 43 | { |
| 44 | EXPECT_EQ(item.expected, handler->canHandleBlob(item.name)); |
| 45 | } |
| 46 | } |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 47 | } // namespace ipmi_flash |