Patrick Venture | 01123b2 | 2019-06-20 13:49:06 -0700 | [diff] [blame] | 1 | #include "helper.hpp" |
| 2 | #include "status.hpp" |
| 3 | |
Patrick Venture | 01123b2 | 2019-06-20 13:49:06 -0700 | [diff] [blame] | 4 | #include <ipmiblob/test/blob_interface_mock.hpp> |
| 5 | |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 6 | #include <cstdint> |
| 7 | |
Patrick Venture | 01123b2 | 2019-06-20 13:49:06 -0700 | [diff] [blame] | 8 | #include <gtest/gtest.h> |
| 9 | |
| 10 | namespace host_tool |
| 11 | { |
| 12 | using ::testing::Return; |
| 13 | using ::testing::TypedEq; |
| 14 | |
| 15 | class UpdaterTest : public ::testing::Test |
| 16 | { |
| 17 | protected: |
| 18 | ipmiblob::BlobInterfaceMock blobMock; |
| 19 | std::uint16_t session = 0xbeef; |
| 20 | }; |
| 21 | |
| 22 | TEST_F(UpdaterTest, PollStatusReturnsAfterSuccess) |
| 23 | { |
| 24 | ipmiblob::StatResponse verificationResponse = {}; |
| 25 | /* the other details of the response are ignored, and should be. */ |
| 26 | verificationResponse.metadata.push_back( |
| 27 | static_cast<std::uint8_t>(ipmi_flash::ActionStatus::success)); |
| 28 | |
| 29 | EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session))) |
| 30 | .WillOnce(Return(verificationResponse)); |
| 31 | |
| 32 | EXPECT_TRUE(pollStatus(session, &blobMock)); |
| 33 | } |
| 34 | |
| 35 | TEST_F(UpdaterTest, PollStatusReturnsAfterFailure) |
| 36 | { |
| 37 | ipmiblob::StatResponse verificationResponse = {}; |
| 38 | /* the other details of the response are ignored, and should be. */ |
| 39 | verificationResponse.metadata.push_back( |
| 40 | static_cast<std::uint8_t>(ipmi_flash::ActionStatus::failed)); |
| 41 | |
| 42 | EXPECT_CALL(blobMock, getStat(TypedEq<std::uint16_t>(session))) |
| 43 | .WillOnce(Return(verificationResponse)); |
| 44 | |
| 45 | EXPECT_FALSE(pollStatus(session, &blobMock)); |
| 46 | } |
| 47 | |
| 48 | } // namespace host_tool |