blob: 600be4b329205157544ffab0713406837743d768 [file] [log] [blame]
Patrick Venture1cde5f92018-11-07 08:26:47 -08001#include "data_mock.hpp"
Patrick Venturedf848ee2018-11-06 15:44:00 -08002#include "firmware_handler.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08003#include "image_mock.hpp"
Patrick Venturedf848ee2018-11-06 15:44:00 -08004
5#include <memory>
6#include <vector>
7
8#include <gtest/gtest.h>
9
10namespace blobs
11{
12TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk)
13{
Patrick Venturedf848ee2018-11-06 15:44:00 -080014 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 Venturea78e39f2018-11-06 18:37:06 -080023 ImageHandlerMock imageMock;
24
25 std::vector<HandlerPack> blobs = {
26 {"asdf", &imageMock},
27 {"bcdf", &imageMock},
28 };
Patrick Venture1cde5f92018-11-07 08:26:47 -080029 std::vector<DataHandlerPack> data = {
Patrick Venture9158dcf2018-11-08 09:44:28 -080030 {FirmwareBlobHandler::FirmwareUpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080031 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080032
Patrick Venture1cde5f92018-11-07 08:26:47 -080033 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
Patrick Venturedf848ee2018-11-06 15:44:00 -080034
35 for (const auto& item : items)
36 {
37 EXPECT_EQ(item.expected, handler->canHandleBlob(item.name));
38 }
39}
40} // namespace blobs