bmc: verificationPending: deleteBlob(blob)

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Icfd8b04a29debe61c4f2d4a3512e636a1eb912ba
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 172281c..e519ccb 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -123,7 +123,8 @@
              */
             return false;
         case UpdateState::verificationPending:
-            break;
+            abortProcess();
+            return true;
         case UpdateState::updatePending:
             break;
         default:
diff --git a/test/firmware_state_verificationpending_unittest.cpp b/test/firmware_state_verificationpending_unittest.cpp
index b7c1bfc..92ba15b 100644
--- a/test/firmware_state_verificationpending_unittest.cpp
+++ b/test/firmware_state_verificationpending_unittest.cpp
@@ -64,8 +64,70 @@
 }
 
 /*
- * delete(blob) TODO: Implement this.
+ * delete(blob)
  */
+TEST_F(FirmwareHandlerVerificationPendingTest, DeleteVerifyPendingAbortsProcess)
+{
+    /* It doesn't matter what blob id is used to delete in the design, so just
+     * delete the verify blob id
+     */
+    getToVerificationPending(staticLayoutBlobId);
+
+    EXPECT_CALL(*verifyMockPtr, abort()).Times(0);
+
+    ASSERT_TRUE(handler->canHandleBlob(verifyBlobId));
+    EXPECT_TRUE(handler->deleteBlob(verifyBlobId));
+
+    std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+    EXPECT_THAT(handler->getBlobIds(),
+                UnorderedElementsAreArray(expectedBlobs));
+    expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
+
+TEST_F(FirmwareHandlerVerificationPendingTest, DeleteActiveImageAbortsProcess)
+{
+    getToVerificationPending(staticLayoutBlobId);
+
+    EXPECT_CALL(*verifyMockPtr, abort()).Times(0);
+
+    ASSERT_TRUE(handler->canHandleBlob(activeImageBlobId));
+    EXPECT_TRUE(handler->deleteBlob(activeImageBlobId));
+
+    std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+    EXPECT_THAT(handler->getBlobIds(),
+                UnorderedElementsAreArray(expectedBlobs));
+    expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
+
+TEST_F(FirmwareHandlerVerificationPendingTest, DeleteStaticLayoutAbortsProcess)
+{
+    getToVerificationPending(staticLayoutBlobId);
+
+    EXPECT_CALL(*verifyMockPtr, abort()).Times(0);
+
+    ASSERT_TRUE(handler->canHandleBlob(staticLayoutBlobId));
+    EXPECT_TRUE(handler->deleteBlob(staticLayoutBlobId));
+
+    std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+    EXPECT_THAT(handler->getBlobIds(),
+                UnorderedElementsAreArray(expectedBlobs));
+    expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
+
+TEST_F(FirmwareHandlerVerificationPendingTest, DeleteHashAbortsProcess)
+{
+    getToVerificationPending(staticLayoutBlobId);
+
+    EXPECT_CALL(*verifyMockPtr, abort()).Times(0);
+
+    ASSERT_TRUE(handler->canHandleBlob(hashBlobId));
+    EXPECT_TRUE(handler->deleteBlob(hashBlobId));
+
+    std::vector<std::string> expectedBlobs = {staticLayoutBlobId, hashBlobId};
+    EXPECT_THAT(handler->getBlobIds(),
+                UnorderedElementsAreArray(expectedBlobs));
+    expectedState(FirmwareBlobHandler::UpdateState::notYetStarted);
+}
 
 /*
  * stat(blob)