blob: 4efae9411f0daa895b1503fa4dc1f82e408c1415 [file] [log] [blame]
Patrick Venture46637c82018-11-06 15:20:24 -08001#include "firmware_handler.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08002#include "image_mock.hpp"
Patrick Venture1d66fe62019-06-03 14:57:27 -07003#include "triggerable_mock.hpp"
Patrick Venture7dad86f2019-05-17 08:52:20 -07004#include "util.hpp"
Patrick Venture46637c82018-11-06 15:20:24 -08005
Patrick Venturea78e39f2018-11-06 18:37:06 -08006#include <vector>
Patrick Venture46637c82018-11-06 15:20:24 -08007
8#include <gtest/gtest.h>
9
Patrick Venture1d5a31c2019-05-20 11:38:22 -070010namespace ipmi_flash
Patrick Venture46637c82018-11-06 15:20:24 -080011{
12TEST(FirmwareHandlerStatTest, StatOnInactiveBlobIDReturnsTransport)
13{
14 /* Test that the metadata information returned matches expectations for this
15 * case.
16 *
17 * canHandle has already been called at this point, so we don't need to test
18 * the input for this function.
19 */
20
Patrick Venturea78e39f2018-11-06 18:37:06 -080021 ImageHandlerMock imageMock;
22
23 std::vector<HandlerPack> blobs = {
Patrick Venture7dad86f2019-05-17 08:52:20 -070024 {hashBlobId, &imageMock},
Patrick Venturea78e39f2018-11-06 18:37:06 -080025 {"asdf", &imageMock},
26 };
Patrick Venture1cde5f92018-11-07 08:26:47 -080027 std::vector<DataHandlerPack> data = {
Patrick Venture05abf7e2018-11-09 11:02:56 -080028 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080029 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080030
Patrick Venture4eb55952018-11-16 15:36:24 -080031 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture1d66fe62019-06-03 14:57:27 -070032 blobs, data, CreateTriggerMock(), CreateTriggerMock());
Patrick Venture4eb55952018-11-16 15:36:24 -080033
Patrick Venturee312f392019-06-04 07:44:37 -070034 blobs::BlobMeta meta;
Patrick Venture46637c82018-11-06 15:20:24 -080035 EXPECT_TRUE(handler->stat("asdf", &meta));
Patrick Venture05abf7e2018-11-09 11:02:56 -080036 EXPECT_EQ(FirmwareBlobHandler::UpdateFlags::ipmi, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080037}
38
Patrick Venture1d5a31c2019-05-20 11:38:22 -070039} // namespace ipmi_flash