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