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 | 7dad86f | 2019-05-17 08:52:20 -0700 | [diff] [blame] | 4 | #include "util.hpp" |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 5 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 6 | #include <sdbusplus/test/sdbus_mock.hpp> |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 7 | #include <vector> |
| 8 | |
| 9 | #include <gtest/gtest.h> |
| 10 | |
| 11 | namespace blobs |
| 12 | { |
| 13 | TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk) |
| 14 | { |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 15 | struct ListItem |
| 16 | { |
| 17 | std::string name; |
| 18 | bool expected; |
| 19 | }; |
| 20 | |
| 21 | std::vector<ListItem> items = { |
| 22 | {"asdf", true}, {"nope", false}, {"123123", false}, {"bcdf", true}}; |
| 23 | |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 24 | ImageHandlerMock imageMock; |
| 25 | |
| 26 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 7dad86f | 2019-05-17 08:52:20 -0700 | [diff] [blame] | 27 | {hashBlobId, &imageMock}, |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 28 | {"asdf", &imageMock}, |
| 29 | {"bcdf", &imageMock}, |
| 30 | }; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 31 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 32 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 33 | }; |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 34 | |
Patrick Venture | 4eb5595 | 2018-11-16 15:36:24 -0800 | [diff] [blame] | 35 | sdbusplus::SdBusMock sdbus_mock; |
| 36 | auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock); |
| 37 | |
| 38 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
Patrick Venture | 74059d6 | 2019-05-17 10:40:26 -0700 | [diff] [blame^] | 39 | std::move(bus_mock), blobs, data, ""); |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 40 | |
| 41 | for (const auto& item : items) |
| 42 | { |
| 43 | EXPECT_EQ(item.expected, handler->canHandleBlob(item.name)); |
| 44 | } |
| 45 | } |
| 46 | } // namespace blobs |