test: firmware verificationPending: commit

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I535b767c1e479ac676418cb41c03318c9b8683a6
diff --git a/test/firmware_state_verificationpending_unittest.cpp b/test/firmware_state_verificationpending_unittest.cpp
index 155252e..6b9b308 100644
--- a/test/firmware_state_verificationpending_unittest.cpp
+++ b/test/firmware_state_verificationpending_unittest.cpp
@@ -176,6 +176,23 @@
 }
 
 /*
+ * commit(session)
+ */
+TEST_F(FirmwareHandlerVerificationPendingTest,
+       CommitOnVerifyBlobTriggersVerificationAndStateTransition)
+{
+    getToVerificationPending(staticLayoutBlobId);
+    EXPECT_TRUE(handler->open(session, flags, verifyBlobId));
+    EXPECT_CALL(*verifyMockPtr, triggerVerification()).WillOnce(Return(true));
+
+    EXPECT_TRUE(handler->commit(session, {}));
+
+    auto realHandler = dynamic_cast<FirmwareBlobHandler*>(handler.get());
+    EXPECT_EQ(FirmwareBlobHandler::UpdateState::verificationStarted,
+              realHandler->getCurrentState());
+}
+
+/*
  * stat(session) - in this state, you can only open(verifyBlobId) without
  * changing state.
  */
@@ -189,9 +206,6 @@
 /*
  * read(session)
  */
-/*
- * commit(session)
- */
 
 } // namespace
 } // namespace ipmi_flash
diff --git a/test/firmware_unittest.hpp b/test/firmware_unittest.hpp
index 1f1ae86..d2eaa2c 100644
--- a/test/firmware_unittest.hpp
+++ b/test/firmware_unittest.hpp
@@ -18,21 +18,27 @@
 class IpmiOnlyFirmwareStaticTest : public ::testing::Test
 {
   protected:
-    ImageHandlerMock imageMock;
-    std::vector<HandlerPack> blobs;
-    std::vector<DataHandlerPack> data = {
-        {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}};
-    std::unique_ptr<blobs::GenericBlobInterface> handler;
-
     void SetUp() override
     {
         blobs = {
             {hashBlobId, &imageMock},
             {staticLayoutBlobId, &imageMock},
         };
+
+        std::unique_ptr<VerificationInterface> verifyMock =
+            std::make_unique<VerificationMock>();
+        verifyMockPtr = reinterpret_cast<VerificationMock*>(verifyMock.get());
+
         handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-            blobs, data, CreateVerifyMock(), CreateUpdateMock());
+            blobs, data, std::move(verifyMock), CreateUpdateMock());
     }
+
+    ImageHandlerMock imageMock;
+    std::vector<HandlerPack> blobs;
+    std::vector<DataHandlerPack> data = {
+        {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}};
+    std::unique_ptr<blobs::GenericBlobInterface> handler;
+    VerificationMock* verifyMockPtr;
 };
 
 class IpmiOnlyFirmwareTest : public ::testing::Test