blob: 1c5b30d6b6b9a6681152a16d7265ab73f46c5e47 [file] [log] [blame]
Patrick Venture01123b22019-06-20 13:49:06 -07001#include "helper.hpp"
2#include "status.hpp"
3
Patrick Venture01123b22019-06-20 13:49:06 -07004#include <ipmiblob/test/blob_interface_mock.hpp>
5
Patrick Venture9b37b092020-05-28 20:58:57 -07006#include <cstdint>
7
Patrick Venture01123b22019-06-20 13:49:06 -07008#include <gtest/gtest.h>
9
10namespace host_tool
11{
12using ::testing::Return;
13using ::testing::TypedEq;
14
15class UpdaterTest : public ::testing::Test
16{
17 protected:
18 ipmiblob::BlobInterfaceMock blobMock;
19 std::uint16_t session = 0xbeef;
20};
21
22TEST_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
35TEST_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