49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
#include "testutils/BlobStoreTest.h"
|
|
#include <boost/optional/optional_io.hpp>
|
|
|
|
using blockstore::Key;
|
|
using cpputils::unique_ref;
|
|
using blobstore::Blob;
|
|
using boost::none;
|
|
|
|
|
|
//gtest/boost::optional workaround for working with optional<unique_ref<T>>
|
|
namespace boost {
|
|
std::ostream& operator<<(std::ostream& out, const unique_ref<Blob> &ref) {
|
|
out << "[" << ref->key().ToString() << "]" << ref.get();
|
|
return out;
|
|
}
|
|
}
|
|
|
|
TEST_F(BlobStoreTest, LoadNonexistingKeyOnEmptyBlobstore) {
|
|
const blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972");
|
|
EXPECT_EQ(none, blobStore->load(key));
|
|
}
|
|
|
|
TEST_F(BlobStoreTest, LoadNonexistingKeyOnNonEmptyBlobstore) {
|
|
blobStore->create();
|
|
const blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972");
|
|
EXPECT_EQ(none, blobStore->load(key));
|
|
}
|
|
|
|
TEST_F(BlobStoreTest, TwoCreatedBlobsHaveDifferentKeys) {
|
|
auto blob1 = blobStore->create();
|
|
auto blob2 = blobStore->create();
|
|
EXPECT_NE(blob1->key(), blob2->key());
|
|
}
|
|
|
|
TEST_F(BlobStoreTest, BlobIsNotLoadableAfterDeletion_DeleteDirectly) {
|
|
auto blob = blobStore->create();
|
|
Key key = blob->key();
|
|
blobStore->remove(std::move(blob));
|
|
EXPECT_FALSE((bool)blobStore->load(key));
|
|
}
|
|
|
|
TEST_F(BlobStoreTest, BlobIsNotLoadableAfterDeletion_DeleteAfterLoading) {
|
|
auto blob = blobStore->create();
|
|
Key key = blob->key();
|
|
reset(std::move(blob));
|
|
blobStore->remove(loadBlob(key));
|
|
EXPECT_FALSE((bool)blobStore->load(key));
|
|
}
|