binarystore: Initial implementation
Dummy BinaryStore class implementation where most functions just return.
Implement getBaseBlobId/getBlobIds/canHandleBlobId and add unit tests
using real objects.
Signed-off-by: Kun Yi <kunyi@google.com>
Change-Id: Iaf8c59f3c4b1bab9de186333074a9cd0160a5764
diff --git a/binarystore_mock.hpp b/binarystore_mock.hpp
index 7792e74..eae08fe 100644
--- a/binarystore_mock.hpp
+++ b/binarystore_mock.hpp
@@ -4,14 +4,25 @@
#include <gmock/gmock.h>
+using ::testing::Invoke;
+
namespace binstore
{
class MockBinaryStore : public BinaryStoreInterface
{
public:
+ MockBinaryStore(const std::string& baseBlobId, int fd, uint32_t offset,
+ uint32_t maxSize) :
+ real_store_(baseBlobId, fd, offset, maxSize)
+ {
+ // Implemented calls in BinaryStore will be directed to the real object.
+ ON_CALL(*this, getBaseBlobId)
+ .WillByDefault(Invoke(&real_store_, &BinaryStore::getBaseBlobId));
+ ON_CALL(*this, getBlobIds)
+ .WillByDefault(Invoke(&real_store_, &BinaryStore::getBlobIds));
+ }
MOCK_CONST_METHOD0(getBaseBlobId, std::string());
- MOCK_CONST_METHOD1(canHandleBlob, bool(const std::string&));
MOCK_CONST_METHOD0(getBlobIds, std::vector<std::string>());
MOCK_METHOD2(openOrCreateBlob, bool(const std::string&, uint16_t));
MOCK_METHOD1(deleteBlob, bool(const std::string&));
@@ -20,6 +31,9 @@
MOCK_METHOD0(commit, bool());
MOCK_METHOD0(close, bool());
MOCK_METHOD0(stat, bool());
+
+ private:
+ BinaryStore real_store_;
};
} // namespace binstore