From 91550128a59d336a8bc1a01d4ec53e28bcdcc425 Mon Sep 17 00:00:00 2001
From: gvolfing <gabor.volfinger@memgraph.io>
Date: Mon, 7 Nov 2022 11:46:24 +0100
Subject: [PATCH] Conform unit test with the new error-handling

---
 tests/unit/storage_v3.cpp | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/tests/unit/storage_v3.cpp b/tests/unit/storage_v3.cpp
index b62606a8e..3098acbdb 100644
--- a/tests/unit/storage_v3.cpp
+++ b/tests/unit/storage_v3.cpp
@@ -33,6 +33,12 @@
 
 using testing::UnorderedElementsAre;
 
+namespace {
+
+class AlreadyInsertedException : public std::exception {};
+
+}  // namespace
+
 namespace memgraph::storage::v3::tests {
 
 class StorageV3 : public ::testing::TestWithParam<bool> {
@@ -2650,14 +2656,21 @@ TEST_P(StorageV3, TestCreateVertexAndValidate) {
               (std::map<PropertyId, PropertyValue>{{prop1, PropertyValue(111)}}));
   }
   {
-    ASSERT_DEATH(
+    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}}, {});
+
+          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);
   }
   {
     auto acc = store.Access(GetNextHlc());