blob: 4c90735610b939d015a76c959cbf02e2a66de04c [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 Venture7dad86f2019-05-17 08:52:20 -07003#include "util.hpp"
Patrick Venture46637c82018-11-06 15:20:24 -08004
Patrick Venture4eb55952018-11-16 15:36:24 -08005#include <sdbusplus/test/sdbus_mock.hpp>
Patrick Venturea78e39f2018-11-06 18:37:06 -08006#include <vector>
Patrick Venture46637c82018-11-06 15:20:24 -08007
8#include <gtest/gtest.h>
9
10namespace blobs
11{
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 sdbusplus::SdBusMock sdbus_mock;
32 auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
33
34 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
35 std::move(bus_mock), blobs, data);
36
Patrick Venture46637c82018-11-06 15:20:24 -080037 struct BlobMeta meta;
38 EXPECT_TRUE(handler->stat("asdf", &meta));
Patrick Venture05abf7e2018-11-09 11:02:56 -080039 EXPECT_EQ(FirmwareBlobHandler::UpdateFlags::ipmi, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080040}
41
42} // namespace blobs