blob: 7fb4c7f84edaf19e4582cec9559c48b0a8454ec2 [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 Venture1d66fe62019-06-03 14:57:27 -07004#include "triggerable_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07005#include "util.hpp"
Patrick Venturedf848ee2018-11-06 15:44:00 -08006
Patrick Venturedf848ee2018-11-06 15:44:00 -08007#include <vector>
8
9#include <gtest/gtest.h>
10
Patrick Venture1d5a31c2019-05-20 11:38:22 -070011namespace ipmi_flash
Patrick Venturedf848ee2018-11-06 15:44:00 -080012{
13TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk)
14{
Patrick Venturedf848ee2018-11-06 15:44:00 -080015 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 Venturea78e39f2018-11-06 18:37:06 -080024 ImageHandlerMock imageMock;
25
26 std::vector<HandlerPack> blobs = {
Patrick Venture7dad86f2019-05-17 08:52:20 -070027 {hashBlobId, &imageMock},
Patrick Venturea78e39f2018-11-06 18:37:06 -080028 {"asdf", &imageMock},
29 {"bcdf", &imageMock},
30 };
Patrick Venture1cde5f92018-11-07 08:26:47 -080031 std::vector<DataHandlerPack> data = {
Patrick Venture05abf7e2018-11-09 11:02:56 -080032 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080033 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080034
Patrick Venture4eb55952018-11-16 15:36:24 -080035 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture1d66fe62019-06-03 14:57:27 -070036 blobs, data, CreateTriggerMock(), CreateTriggerMock());
Patrick Venturedf848ee2018-11-06 15:44:00 -080037
38 for (const auto& item : items)
39 {
40 EXPECT_EQ(item.expected, handler->canHandleBlob(item.name));
41 }
42}
Patrick Venture1d5a31c2019-05-20 11:38:22 -070043} // namespace ipmi_flash