blob: becb3f18c28455223dc7d5e181b461d216e5c1fb [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 Venture3ecb3502019-05-17 11:03:51 -07004#include "verification_mock.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
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 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venture3ecb3502019-05-17 11:03:51 -070032 blobs, data, CreateVerifyMock());
Patrick Venture4eb55952018-11-16 15:36:24 -080033
Patrick Venture46637c82018-11-06 15:20:24 -080034 struct BlobMeta meta;
35 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
39} // namespace blobs