blob: 44223d4e085b1e19ad5b324498a2f8725ca5db98 [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 = {
Patrick Venture18235e62018-11-08 10:21:09 -080026 {FirmwareBlobHandler::hashBlobID, &imageMock},
Patrick Venturea78e39f2018-11-06 18:37:06 -080027 {"asdf", &imageMock},
28 {"bcdf", &imageMock},
29 };
Patrick Venture1cde5f92018-11-07 08:26:47 -080030 std::vector<DataHandlerPack> data = {
Patrick Venture9158dcf2018-11-08 09:44:28 -080031 {FirmwareBlobHandler::FirmwareUpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080032 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080033
Patrick Venture1cde5f92018-11-07 08:26:47 -080034 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data);
Patrick Venturedf848ee2018-11-06 15:44:00 -080035
36 for (const auto& item : items)
37 {
38 EXPECT_EQ(item.expected, handler->canHandleBlob(item.name));
39 }
40}
41} // namespace blobs