2015-03-06 02:21:20 +01:00
|
|
|
#include "testutils/BlobStoreTest.h"
|
2015-06-21 17:43:45 +02:00
|
|
|
#include <messmer/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h>
|
2015-03-06 02:21:20 +01:00
|
|
|
|
|
|
|
using blockstore::Key;
|
2015-06-18 12:45:37 +02:00
|
|
|
using cpputils::unique_ref;
|
|
|
|
using blobstore::Blob;
|
|
|
|
using boost::none;
|
|
|
|
|
2015-03-06 02:32:43 +01:00
|
|
|
TEST_F(BlobStoreTest, LoadNonexistingKeyOnEmptyBlobstore) {
|
|
|
|
const blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972");
|
2015-06-18 12:45:37 +02:00
|
|
|
EXPECT_EQ(none, blobStore->load(key));
|
2015-03-06 02:32:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BlobStoreTest, LoadNonexistingKeyOnNonEmptyBlobstore) {
|
|
|
|
blobStore->create();
|
|
|
|
const blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972");
|
2015-06-18 12:45:37 +02:00
|
|
|
EXPECT_EQ(none, blobStore->load(key));
|
2015-03-06 02:32:43 +01:00
|
|
|
}
|
|
|
|
|
2015-03-06 02:21:20 +01:00
|
|
|
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));
|
2015-06-18 12:45:37 +02:00
|
|
|
EXPECT_FALSE((bool)blobStore->load(key));
|
2015-03-06 02:21:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BlobStoreTest, BlobIsNotLoadableAfterDeletion_DeleteAfterLoading) {
|
|
|
|
auto blob = blobStore->create();
|
|
|
|
Key key = blob->key();
|
2015-06-18 12:45:37 +02:00
|
|
|
reset(std::move(blob));
|
|
|
|
blobStore->remove(loadBlob(key));
|
|
|
|
EXPECT_FALSE((bool)blobStore->load(key));
|
2015-03-06 02:21:20 +01:00
|
|
|
}
|