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