Modify unit test
Instead of Creating an exception that is would be only used in this file, just assert the type of the error the double vertex insertion operation should yield.
This commit is contained in:
parent
91550128a5
commit
79756ae6fb
@ -33,12 +33,6 @@
|
||||
|
||||
using testing::UnorderedElementsAre;
|
||||
|
||||
namespace {
|
||||
|
||||
class AlreadyInsertedException : public std::exception {};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace memgraph::storage::v3::tests {
|
||||
|
||||
class StorageV3 : public ::testing::TestWithParam<bool> {
|
||||
@ -2656,21 +2650,16 @@ TEST_P(StorageV3, TestCreateVertexAndValidate) {
|
||||
(std::map<PropertyId, PropertyValue>{{prop1, PropertyValue(111)}}));
|
||||
}
|
||||
{
|
||||
EXPECT_THROW(
|
||||
{
|
||||
Shard store(primary_label, min_pk, std::nullopt /*max_primary_key*/, schema_property_vector);
|
||||
auto acc = store.Access(GetNextHlc());
|
||||
auto vertex1 = acc.CreateVertexAndValidate({}, {PropertyValue{0}}, {});
|
||||
auto vertex2 = acc.CreateVertexAndValidate({}, {PropertyValue{0}}, {});
|
||||
Shard store(primary_label, min_pk, std::nullopt /*max_primary_key*/, schema_property_vector);
|
||||
auto acc = store.Access(GetNextHlc());
|
||||
auto vertex1 = acc.CreateVertexAndValidate({}, {PropertyValue{0}}, {});
|
||||
auto vertex2 = acc.CreateVertexAndValidate({}, {PropertyValue{0}}, {});
|
||||
|
||||
if (vertex2.HasError()) {
|
||||
auto error = vertex2.GetError();
|
||||
if (auto error_ptr = std::get_if<memgraph::storage::v3::Error>(&error)) {
|
||||
if (*error_ptr == storage::v3::Error::VERTEX_ALREADY_INSERTED) throw AlreadyInsertedException();
|
||||
}
|
||||
}
|
||||
},
|
||||
AlreadyInsertedException);
|
||||
ASSERT_TRUE(vertex2.HasError());
|
||||
auto error = vertex2.GetError();
|
||||
auto error_ptr = std::get_if<memgraph::storage::v3::Error>(&error);
|
||||
ASSERT_TRUE(error_ptr);
|
||||
ASSERT_TRUE(*error_ptr == storage::v3::Error::VERTEX_ALREADY_INSERTED);
|
||||
}
|
||||
{
|
||||
auto acc = store.Access(GetNextHlc());
|
||||
|
Loading…
Reference in New Issue
Block a user