blob: d36304b6402f4a7f069e532fbd4c9283894f5281 [file] [log] [blame]
Patrick Ventureaa32a362018-12-13 10:52:33 -08001#include "blob_interface_mock.hpp"
2#include "data_interface_mock.hpp"
3#include "updater.hpp"
4
5#include <string>
6
7#include <gtest/gtest.h>
8
9using ::testing::Eq;
10using ::testing::Return;
11using ::testing::StrEq;
12
13TEST(UpdaterTest, NormalWalkthroughAllHappy)
14{
15 /* Call updaterMain and have everything respond happily. */
16 DataInterfaceMock handlerMock;
17 BlobInterfaceMock blobMock;
18 std::string firmwareImage = "image.bin";
19 std::string signatureFile = "image.sig";
20
21 std::vector<std::string> blobList = {"/flash/image"};
22 StatResponse statObj;
23 statObj.blob_state = blobs::FirmwareBlobHandler::UpdateFlags::ipmi |
24 blobs::FirmwareBlobHandler::UpdateFlags::lpc;
25 statObj.size = 0;
26 blobs::FirmwareBlobHandler::UpdateFlags supported =
27 blobs::FirmwareBlobHandler::UpdateFlags::lpc;
28 std::uint16_t session = 0xbeef;
29
30 EXPECT_CALL(blobMock, getBlobList()).WillOnce(Return(blobList));
31
32 EXPECT_CALL(blobMock, getStat(StrEq(blobList[0].c_str())))
33 .WillOnce(Return(statObj));
34
35 EXPECT_CALL(handlerMock, supportedType()).WillOnce(Return(supported));
36
37 EXPECT_CALL(blobMock, openBlob(StrEq(blobList[0].c_str()), Eq(supported)))
38 .WillOnce(Return(session));
39
40 EXPECT_CALL(handlerMock,
41 sendContents(StrEq(firmwareImage.c_str()), Eq(session)))
42 .WillOnce(Return(true));
43
44 updaterMain(&blobMock, &handlerMock, firmwareImage, signatureFile);
45}