blob: 5ad48a505dd83e2878434457252ea17e3111df8b [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
Patrick Venturedf848ee2018-11-06 15:44:00 -08005#include <vector>
6
7#include <gtest/gtest.h>
8
9namespace blobs
10{
11TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk)
12{
Patrick Venturedf848ee2018-11-06 15:44:00 -080013 struct ListItem
14 {
15 std::string name;
16 bool expected;
17 };
18
19 std::vector<ListItem> items = {
20 {"asdf", true}, {"nope", false}, {"123123", false}, {"bcdf", true}};
21
Patrick Venturea78e39f2018-11-06 18:37:06 -080022 ImageHandlerMock imageMock;
23
24 std::vector<HandlerPack> blobs = {
Patrick Venture18235e62018-11-08 10:21:09 -080025 {FirmwareBlobHandler::hashBlobID, &imageMock},
Patrick Venturea78e39f2018-11-06 18:37:06 -080026 {"asdf", &imageMock},
27 {"bcdf", &imageMock},
28 };
Patrick Venture1cde5f92018-11-07 08:26:47 -080029 std::vector<DataHandlerPack> data = {
Patrick Venture05abf7e2018-11-09 11:02:56 -080030 {FirmwareBlobHandler::UpdateFlags::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