#include "ipmi.hpp" #include "manager_mock.hpp" #include #include #include namespace blobs { using ::testing::Return; TEST(BlobCloseTest, ManagerRejectsCloseReturnsFailure) { // The session manager returned failure to close, which we need to pass on. ManagerMock mgr; uint16_t sessionId = 0x54; size_t dataLen; std::vector request; struct BmcBlobCloseTx req; req.crc = 0; req.sessionId = sessionId; dataLen = sizeof(req); request.resize(dataLen); std::memcpy(request.data(), &req, dataLen); EXPECT_CALL(mgr, close(sessionId)).WillOnce(Return(false)); EXPECT_EQ(ipmi::responseUnspecifiedError(), closeBlob(&mgr, request)); } TEST(BlobCloseTest, BlobClosedReturnsSuccess) { // Verify that if all goes right, success is returned. ManagerMock mgr; uint16_t sessionId = 0x54; size_t dataLen; std::vector request; struct BmcBlobCloseTx req; req.crc = 0; req.sessionId = sessionId; dataLen = sizeof(req); request.resize(dataLen); std::memcpy(request.data(), &req, dataLen); EXPECT_CALL(mgr, close(sessionId)).WillOnce(Return(true)); EXPECT_EQ(ipmi::responseSuccess(std::vector{}), closeBlob(&mgr, request)); } } // namespace blobs