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 | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 3 | #include "image_mock.hpp" |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 4 | |
| 5 | #include <memory> |
| 6 | #include <vector> |
| 7 | |
| 8 | #include <gtest/gtest.h> |
| 9 | |
| 10 | namespace blobs |
| 11 | { |
| 12 | TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk) |
| 13 | { |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 14 | struct ListItem |
| 15 | { |
| 16 | std::string name; |
| 17 | bool expected; |
| 18 | }; |
| 19 | |
| 20 | std::vector<ListItem> items = { |
| 21 | {"asdf", true}, {"nope", false}, {"123123", false}, {"bcdf", true}}; |
| 22 | |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 23 | ImageHandlerMock imageMock; |
| 24 | |
| 25 | std::vector<HandlerPack> blobs = { |
| 26 | {"asdf", &imageMock}, |
| 27 | {"bcdf", &imageMock}, |
| 28 | }; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 29 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 9158dcf | 2018-11-08 09:44:28 -0800 | [diff] [blame^] | 30 | {FirmwareBlobHandler::FirmwareUpdateFlags::ipmi, nullptr}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 31 | }; |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 32 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 33 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data); |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 34 | |
| 35 | for (const auto& item : items) |
| 36 | { |
| 37 | EXPECT_EQ(item.expected, handler->canHandleBlob(item.name)); |
| 38 | } |
| 39 | } |
| 40 | } // namespace blobs |