blob: bc7417c0136aedebbbd24f5165c68c919d6aa66f [file] [log] [blame]
#include "blob_interface_mock.hpp"
#include "data_interface_mock.hpp"
#include "updater.hpp"
#include <string>
#include <gtest/gtest.h>
using ::testing::Eq;
using ::testing::Return;
using ::testing::StrEq;
TEST(UpdaterTest, NormalWalkthroughAllHappy)
{
/* Call updaterMain and have everything respond happily. */
DataInterfaceMock handlerMock;
BlobInterfaceMock blobMock;
std::string firmwareImage = "image.bin";
std::string signatureFile = "image.sig";
std::string expectedBlob = "/flash/image";
std::vector<std::string> blobList = {expectedBlob};
StatResponse statObj;
statObj.blob_state = blobs::FirmwareBlobHandler::UpdateFlags::ipmi |
blobs::FirmwareBlobHandler::UpdateFlags::lpc;
statObj.size = 0;
blobs::FirmwareBlobHandler::UpdateFlags supported =
blobs::FirmwareBlobHandler::UpdateFlags::lpc;
std::uint16_t session = 0xbeef;
EXPECT_CALL(blobMock, getBlobList()).WillOnce(Return(blobList));
EXPECT_CALL(blobMock, getStat(Eq(expectedBlob))).WillOnce(Return(statObj));
EXPECT_CALL(handlerMock, supportedType()).WillOnce(Return(supported));
EXPECT_CALL(blobMock, openBlob(StrEq(expectedBlob.c_str()), Eq(supported)))
.WillOnce(Return(session));
EXPECT_CALL(handlerMock,
sendContents(StrEq(firmwareImage.c_str()), Eq(session)))
.WillOnce(Return(true));
updaterMain(&blobMock, &handlerMock, firmwareImage, signatureFile);
}