binarystore: Enable maxBinarySize Feature
Fail on write() and commit() if the result will exceed the max size.
Enabled by adding the max_binary_size to the proto buffer. The new one
takes priority and will replace existing one even if it already exists.
The `max_binary_size` is the size of the total data including the size
header. It is calculated with
```
blob_.SerializeAsString().size() +
sizeof(boost::endian::little_uint64_t)
```
Change-Id: I28a4c7a25fa066c11510b51cdfce27df4e09d3b5
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/binarystore_mock.hpp b/binarystore_mock.hpp
index fa6c787..9360dd3 100644
--- a/binarystore_mock.hpp
+++ b/binarystore_mock.hpp
@@ -5,6 +5,7 @@
#include "sys_file.hpp"
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -19,8 +20,9 @@
{
public:
MockBinaryStore(const std::string& baseBlobId,
- std::unique_ptr<SysFile> file) :
- real_store_(baseBlobId, std::move(file))
+ std::unique_ptr<SysFile> file,
+ std::optional<uint32_t> maxSize = std::nullopt) :
+ real_store_(baseBlobId, std::move(file), maxSize)
{
// Implemented calls in BinaryStore will be directed to the real object.
ON_CALL(*this, getBaseBlobId)