blob: 54c8be46a9c172228c61597d8e78a6f4828a97fa [file] [log] [blame]
Patrick Venture27ac5822019-05-20 17:39:31 -07001#include "bmc_update_mock.hpp"
Patrick Venture46637c82018-11-06 15:20:24 -08002#include "firmware_handler.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08003#include "image_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07004#include "util.hpp"
Patrick Venture3ecb3502019-05-17 11:03:51 -07005#include "verification_mock.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 Venture05abf7e2018-11-09 11:02:56 -080029 {FirmwareBlobHandler::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 Venture27ac5822019-05-20 17:39:31 -070033 blobs, data, CreateVerifyMock(), CreateUpdateMock());
Patrick Venture4eb55952018-11-16 15:36:24 -080034
Patrick Venture1d5a31c2019-05-20 11:38:22 -070035 struct blobs::BlobMeta meta;
Patrick Venture46637c82018-11-06 15:20:24 -080036 EXPECT_TRUE(handler->stat("asdf", &meta));
Patrick Venture05abf7e2018-11-09 11:02:56 -080037 EXPECT_EQ(FirmwareBlobHandler::UpdateFlags::ipmi, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080038}
39
Patrick Venture1d5a31c2019-05-20 11:38:22 -070040} // namespace ipmi_flash