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 = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame^] | 26 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 27 | {"asdf", &imageMock}, |
| 28 | {"bcdf", &imageMock}, |
| 29 | }; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 30 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 9158dcf | 2018-11-08 09:44:28 -0800 | [diff] [blame] | 31 | {FirmwareBlobHandler::FirmwareUpdateFlags::ipmi, nullptr}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 32 | }; |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 33 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 34 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data); |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 35 | |
| 36 | for (const auto& item : items) |
| 37 | { |
| 38 | EXPECT_EQ(item.expected, handler->canHandleBlob(item.name)); |
| 39 | } |
| 40 | } |
| 41 | } // namespace blobs |