From 79756ae6fbf58453733f5ce8a6ec4ee54b276362 Mon Sep 17 00:00:00 2001 From: gvolfing <gabor.volfinger@memgraph.io> Date: Tue, 8 Nov 2022 07:31:01 +0100 Subject: [PATCH] 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. --- tests/unit/storage_v3.cpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/tests/unit/storage_v3.cpp b/tests/unit/storage_v3.cpp index 3098acbdb..b107786e8 100644 --- a/tests/unit/storage_v3.cpp +++ b/tests/unit/storage_v3.cpp @@ -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());