1 #include "create_action_map.hpp"
2 #include "data_mock.hpp"
3 #include "firmware_handler.hpp"
4 #include "flags.hpp"
5 #include "image_mock.hpp"
6 #include "util.hpp"
7
8 #include <vector>
9
10 #include <gtest/gtest.h>
11
12 namespace ipmi_flash
13 {
TEST(FirmwareHandlerCanHandleTest,VerifyItemsInListAreOk)14 TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk)
15 {
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
25 ImageHandlerMock imageMock;
26
27 std::vector<HandlerPack> blobs;
28 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>());
31
32 std::vector<DataHandlerPack> data;
33 data.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
34
35 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
36 std::move(blobs), std::move(data), CreateActionMap("asdf"));
37
38 for (const auto& item : items)
39 {
40 EXPECT_EQ(item.expected, handler->canHandleBlob(item.name));
41 }
42 }
43 } // namespace ipmi_flash
44