blob: d6cc99d7d55fbf1f4120476238e84d05d37760f6 [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 Venture46637c82018-11-06 15:20:24 -08003
Patrick Venture4eb55952018-11-16 15:36:24 -08004#include <sdbusplus/test/sdbus_mock.hpp>
Patrick Venturea78e39f2018-11-06 18:37:06 -08005#include <vector>
Patrick Venture46637c82018-11-06 15:20:24 -08006
7#include <gtest/gtest.h>
8
9namespace blobs
10{
11TEST(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 Venturea78e39f2018-11-06 18:37:06 -080020 ImageHandlerMock imageMock;
21
22 std::vector<HandlerPack> blobs = {
Patrick Venture18235e62018-11-08 10:21:09 -080023 {FirmwareBlobHandler::hashBlobID, &imageMock},
Patrick Venturea78e39f2018-11-06 18:37:06 -080024 {"asdf", &imageMock},
25 };
Patrick Venture1cde5f92018-11-07 08:26:47 -080026 std::vector<DataHandlerPack> data = {
Patrick Venture05abf7e2018-11-09 11:02:56 -080027 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080028 };
Patrick Venturea78e39f2018-11-06 18:37:06 -080029
Patrick Venture4eb55952018-11-16 15:36:24 -080030 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 Venture46637c82018-11-06 15:20:24 -080036 struct BlobMeta meta;
37 EXPECT_TRUE(handler->stat("asdf", &meta));
Patrick Venture05abf7e2018-11-09 11:02:56 -080038 EXPECT_EQ(FirmwareBlobHandler::UpdateFlags::ipmi, meta.blobState);
Patrick Venture46637c82018-11-06 15:20:24 -080039}
40
41} // namespace blobs