blob: b18b52591d61fe675798a93f8cee6c9945ebd793 [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 Venture84778b82019-06-26 20:11:09 -07003#include "flags.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08004#include "image_mock.hpp"
Patrick Venture1d66fe62019-06-03 14:57:27 -07005#include "triggerable_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07006#include "util.hpp"
Patrick Venturedf848ee2018-11-06 15:44:00 -08007
Patrick Venturedf848ee2018-11-06 15:44:00 -08008#include <vector>
9
10#include <gtest/gtest.h>
11
Patrick Venture1d5a31c2019-05-20 11:38:22 -070012namespace ipmi_flash
Patrick Venturedf848ee2018-11-06 15:44:00 -080013{
14TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk)
15{
Patrick Venturedf848ee2018-11-06 15:44:00 -080016 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
Patrick Venturea78e39f2018-11-06 18:37:06 -080025 ImageHandlerMock imageMock;
26
Patrick Ventured4e20de2019-07-18 12:48:05 -070027 std::vector<HandlerPack> blobs;
28 blobs.push_back(std::move(
29 HandlerPack(hashBlobId, std::make_unique<ImageHandlerMock>())));
30 blobs.push_back(
31 std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
32 blobs.push_back(
33 std::move(HandlerPack("bcdf", std::make_unique<ImageHandlerMock>())));
34
Patrick Venture1cde5f92018-11-07 08:26:47 -080035 std::vector<DataHandlerPack> data = {
Patrick Venture84778b82019-06-26 20:11:09 -070036 {FirmwareFlags::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080037 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080038
Patrick Venture4eb55952018-11-16 15:36:24 -080039 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture7b783432020-09-22 15:55:08 -070040 std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
Patrick Venturedf848ee2018-11-06 15:44:00 -080041
42 for (const auto& item : items)
43 {
44 EXPECT_EQ(item.expected, handler->canHandleBlob(item.name));
45 }
46}
Patrick Venture1d5a31c2019-05-20 11:38:22 -070047} // namespace ipmi_flash