blob: 021dca80364267552dc3c607cf57376307662bdf [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 Venturea78e39f2018-11-06 18:37:06 -08007#include <vector>
Patrick Venture46637c82018-11-06 15:20:24 -08008
9#include <gtest/gtest.h>
10
Patrick Venture1d5a31c2019-05-20 11:38:22 -070011namespace ipmi_flash
Patrick Venture46637c82018-11-06 15:20:24 -080012{
13TEST(FirmwareHandlerStatTest, StatOnInactiveBlobIDReturnsTransport)
14{
15 /* Test that the metadata information returned matches expectations for this
16 * case.
17 *
18 * canHandle has already been called at this point, so we don't need to test
19 * the input for this function.
20 */
21
Patrick Venturea78e39f2018-11-06 18:37:06 -080022 ImageHandlerMock imageMock;
23
24 std::vector<HandlerPack> blobs = {
Patrick Venture7dad86f2019-05-17 08:52:20 -070025 {hashBlobId, &imageMock},
Patrick Venturea78e39f2018-11-06 18:37:06 -080026 {"asdf", &imageMock},
27 };
Patrick Venture1cde5f92018-11-07 08:26:47 -080028 std::vector<DataHandlerPack> data = {
Patrick Venture84778b82019-06-26 20:11:09 -070029 {FirmwareFlags::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080030 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080031
Patrick Venture4eb55952018-11-16 15:36:24 -080032 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture6d7735d2019-06-21 10:03:19 -070033 blobs, data, CreateTriggerMock(), CreateTriggerMock(),
34 CreateTriggerMock());
Patrick Venture4eb55952018-11-16 15:36:24 -080035
Patrick Venturee312f392019-06-04 07:44:37 -070036 blobs::BlobMeta meta;
Patrick Venture46637c82018-11-06 15:20:24 -080037 EXPECT_TRUE(handler->stat("asdf", &meta));
Patrick Venture84778b82019-06-26 20:11:09 -070038 EXPECT_EQ(FirmwareFlags::UpdateFlags::ipmi, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080039}
40
Patrick Venture1d5a31c2019-05-20 11:38:22 -070041} // namespace ipmi_flash