Patrick Venture | 46637c8 | 2018-11-06 15:20:24 -0800 | [diff] [blame] | 1 | #include "firmware_handler.hpp" |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 2 | #include "image_mock.hpp" |
Patrick Venture | 46637c8 | 2018-11-06 15:20:24 -0800 | [diff] [blame] | 3 | |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 4 | #include <vector> |
Patrick Venture | 46637c8 | 2018-11-06 15:20:24 -0800 | [diff] [blame] | 5 | |
| 6 | #include <gtest/gtest.h> |
| 7 | |
| 8 | namespace blobs |
| 9 | { |
| 10 | TEST(FirmwareHandlerStatTest, StatOnInactiveBlobIDReturnsTransport) |
| 11 | { |
| 12 | /* Test that the metadata information returned matches expectations for this |
| 13 | * case. |
| 14 | * |
| 15 | * canHandle has already been called at this point, so we don't need to test |
| 16 | * the input for this function. |
| 17 | */ |
| 18 | |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 19 | ImageHandlerMock imageMock; |
| 20 | |
| 21 | std::vector<HandlerPack> blobs = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 22 | {FirmwareBlobHandler::hashBlobID, &imageMock}, |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 23 | {"asdf", &imageMock}, |
| 24 | }; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 25 | std::vector<DataHandlerPack> data = { |
Patrick Venture | 9158dcf | 2018-11-08 09:44:28 -0800 | [diff] [blame] | 26 | {FirmwareBlobHandler::FirmwareUpdateFlags::ipmi, nullptr}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 27 | }; |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 28 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 29 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, data); |
Patrick Venture | 46637c8 | 2018-11-06 15:20:24 -0800 | [diff] [blame] | 30 | struct BlobMeta meta; |
| 31 | EXPECT_TRUE(handler->stat("asdf", &meta)); |
Patrick Venture | 9158dcf | 2018-11-08 09:44:28 -0800 | [diff] [blame] | 32 | EXPECT_EQ(FirmwareBlobHandler::FirmwareUpdateFlags::ipmi, meta.blobState); |
Patrick Venture | 46637c8 | 2018-11-06 15:20:24 -0800 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | } // namespace blobs |