handler: Implement read/write/close/delete
Implement read/write/close/delete as pass-through functions.
Signed-off-by: Kun Yi <kunyi@google.com>
Change-Id: I56b935b03b8048a70a168d00061c043795b90f5e
diff --git a/test/handler_unittest.cpp b/test/handler_unittest.cpp
index d96fc41..d51818e 100644
--- a/test/handler_unittest.cpp
+++ b/test/handler_unittest.cpp
@@ -103,4 +103,27 @@
EXPECT_EQ(expectedIdList, handler.getBlobIds());
}
+TEST_F(BinaryStoreBlobHandlerBasicTest, DeleteReturnsWhatStoreReturns)
+{
+ auto bstore = std::make_unique<MockBinaryStore>();
+
+ EXPECT_CALL(*bstore, getBaseBlobId())
+ .WillRepeatedly(Return(basicTestBaseId));
+ EXPECT_CALL(*bstore, canHandleBlob(StrNe(basicTestBlobId)))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*bstore, canHandleBlob(StrEq(basicTestBlobId)))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*bstore, deleteBlob(StrEq(basicTestBlobId)))
+ .WillOnce(Return(false))
+ .WillOnce(Return(true));
+ handler.addNewBinaryStore(std::move(bstore));
+
+ // Verify canHandleBlob return true for a blob id that it can handle
+ EXPECT_FALSE(handler.canHandleBlob(basicTestInvalidBlobId));
+ EXPECT_TRUE(handler.canHandleBlob(basicTestBlobId));
+ EXPECT_FALSE(handler.deleteBlob(basicTestInvalidBlobId));
+ EXPECT_FALSE(handler.deleteBlob(basicTestBlobId));
+ EXPECT_TRUE(handler.deleteBlob(basicTestBlobId));
+}
+
} // namespace blobs