blob: 6e97cc83cae97b29fbc79e784d95d9090dd0ccd7 [file] [log] [blame]
Patrick Venture46637c82018-11-06 15:20:24 -08001#include "firmware_handler.hpp"
Patrick Venture84778b82019-06-26 20:11:09 -07002#include "flags.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 Venture46637c82018-11-06 15:20:24 -08006
Patrick Ventured4e20de2019-07-18 12:48:05 -07007#include <memory>
Patrick Venturea78e39f2018-11-06 18:37:06 -08008#include <vector>
Patrick Venture46637c82018-11-06 15:20:24 -08009
10#include <gtest/gtest.h>
11
Patrick Venture1d5a31c2019-05-20 11:38:22 -070012namespace ipmi_flash
Patrick Venture46637c82018-11-06 15:20:24 -080013{
Patrick Ventured4e20de2019-07-18 12:48:05 -070014namespace
15{
16
Patrick Venture46637c82018-11-06 15:20:24 -080017TEST(FirmwareHandlerStatTest, StatOnInactiveBlobIDReturnsTransport)
18{
19 /* Test that the metadata information returned matches expectations for this
20 * case.
21 *
22 * canHandle has already been called at this point, so we don't need to test
23 * the input for this function.
24 */
25
Patrick Ventured4e20de2019-07-18 12:48:05 -070026 std::vector<HandlerPack> blobs;
27 blobs.push_back(std::move(
28 HandlerPack(hashBlobId, std::make_unique<ImageHandlerMock>())));
29 blobs.push_back(
30 std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
Patrick Venturea78e39f2018-11-06 18:37:06 -080031
Patrick Venture1cde5f92018-11-07 08:26:47 -080032 std::vector<DataHandlerPack> data = {
Patrick Venture84778b82019-06-26 20:11:09 -070033 {FirmwareFlags::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080034 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080035
Patrick Venture4eb55952018-11-16 15:36:24 -080036 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Ventured4e20de2019-07-18 12:48:05 -070037 std::move(blobs), data, std::move(CreateActionMap("asdf")));
Patrick Venture4eb55952018-11-16 15:36:24 -080038
Patrick Venturee312f392019-06-04 07:44:37 -070039 blobs::BlobMeta meta;
Patrick Venture46637c82018-11-06 15:20:24 -080040 EXPECT_TRUE(handler->stat("asdf", &meta));
Patrick Venture84778b82019-06-26 20:11:09 -070041 EXPECT_EQ(FirmwareFlags::UpdateFlags::ipmi, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080042}
43
Patrick Ventured4e20de2019-07-18 12:48:05 -070044} // namespace
Patrick Venture1d5a31c2019-05-20 11:38:22 -070045} // namespace ipmi_flash