From 5717dfb165f23537d8fec566897aa2e3902b8af2 Mon Sep 17 00:00:00 2001 From: jbajic Date: Tue, 22 Nov 2022 14:05:04 +0100 Subject: [PATCH] Add ErrorCode to SHARD_ERROR macro --- src/glue/v2/communication.cpp | 2 +- src/storage/v3/edge_accessor.cpp | 20 ++--- src/storage/v3/result.hpp | 6 +- src/storage/v3/schema_validator.cpp | 8 +- src/storage/v3/shard.cpp | 23 +++--- src/storage/v3/vertex_accessor.cpp | 64 +++++++-------- tests/unit/storage_v3.cpp | 90 +++++++++++----------- tests/unit/storage_v3_edge.cpp | 10 +-- tests/unit/storage_v3_schema.cpp | 22 +++--- tests/unit/storage_v3_vertex_accessors.cpp | 12 +-- 10 files changed, 130 insertions(+), 127 deletions(-) diff --git a/src/glue/v2/communication.cpp b/src/glue/v2/communication.cpp index a977e0e29..bc8d2da09 100644 --- a/src/glue/v2/communication.cpp +++ b/src/glue/v2/communication.cpp @@ -112,7 +112,7 @@ BoltResult ToBoltPath(const query::v2::accessors::Pat const msgs::ShardRequestManagerInterface * /*shard_request_manager*/, storage::v3::View /*view*/) { // TODO(jbajic) Fix bolt communication - return {SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)}; + return {SHARD_ERROR(ErrorCode::DELETED_OBJECT)}; } BoltResult ToBoltValue(const query::v2::TypedValue &value, diff --git a/src/storage/v3/edge_accessor.cpp b/src/storage/v3/edge_accessor.cpp index 4438e0acb..95dd6875a 100644 --- a/src/storage/v3/edge_accessor.cpp +++ b/src/storage/v3/edge_accessor.cpp @@ -57,11 +57,11 @@ const VertexId &EdgeAccessor::ToVertex() const { return to_vertex_; } ShardResult EdgeAccessor::SetProperty(PropertyId property, const PropertyValue &value) { utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; - if (!config_.properties_on_edges) return SHARD_ERROR(common::ErrorCode::PROPERTIES_DISABLED); + if (!config_.properties_on_edges) return SHARD_ERROR(ErrorCode::PROPERTIES_DISABLED); - if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (edge_.ptr->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (edge_.ptr->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); auto current_value = edge_.ptr->properties.GetProperty(property); // We could skip setting the value if the previous one is the same to the new @@ -77,11 +77,11 @@ ShardResult EdgeAccessor::SetProperty(PropertyId property, const } ShardResult> EdgeAccessor::ClearProperties() { - if (!config_.properties_on_edges) return SHARD_ERROR(common::ErrorCode::PROPERTIES_DISABLED); + if (!config_.properties_on_edges) return SHARD_ERROR(ErrorCode::PROPERTIES_DISABLED); - if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, edge_.ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (edge_.ptr->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (edge_.ptr->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); auto properties = edge_.ptr->properties.Properties(); for (const auto &property : properties) { @@ -129,8 +129,8 @@ ShardResult EdgeAccessor::GetProperty(PropertyId property, View v break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return std::move(value); } @@ -175,8 +175,8 @@ ShardResult> EdgeAccessor::Properties(View v break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return std::move(properties); } diff --git a/src/storage/v3/result.hpp b/src/storage/v3/result.hpp index 2b5b316bb..136ec0136 100644 --- a/src/storage/v3/result.hpp +++ b/src/storage/v3/result.hpp @@ -42,7 +42,11 @@ struct ShardError { }; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define SHARD_ERROR(...) memgraph::storage::v3::ShardError(__VA_ARGS__, std::experimental::source_location::current()) +#define SHARD_ERROR(...) \ + ({ \ + using ErrorCode = memgraph::common::ErrorCode; \ + memgraph::storage::v3::ShardError(__VA_ARGS__, std::experimental::source_location::current()); \ + }) template using ShardResult = utils::BasicResult; diff --git a/src/storage/v3/schema_validator.cpp b/src/storage/v3/schema_validator.cpp index 97c068524..7854dc389 100644 --- a/src/storage/v3/schema_validator.cpp +++ b/src/storage/v3/schema_validator.cpp @@ -31,14 +31,14 @@ std::optional SchemaValidator::ValidateVertexCreate( // Schema on primary label const auto *schema = schemas_->GetSchema(primary_label); if (schema == nullptr) { - return SHARD_ERROR(common::ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL, + return SHARD_ERROR(ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL, fmt::format("Schema not defined for label :{}", name_id_mapper_->IdToName(primary_label))); } // Is there another primary label among secondary labels for (const auto &secondary_label : labels) { if (schemas_->GetSchema(secondary_label)) { - return SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY, + return SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY, fmt::format("Cannot add label :{}, since it is defined as a primary label", name_id_mapper_->IdToName(secondary_label))); } @@ -46,7 +46,7 @@ std::optional SchemaValidator::ValidateVertexCreate( // Quick size check if (schema->second.size() != primary_properties.size()) { - return SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED, + return SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED, fmt::format("Not all primary properties have been specified for :{} vertex", name_id_mapper_->IdToName(primary_label))); } @@ -88,7 +88,7 @@ std::optional SchemaValidator::ValidatePropertyUpdate(const LabelId std::optional SchemaValidator::ValidateLabelUpdate(const LabelId label) const { const auto *schema = schemas_->GetSchema(label); if (schema) { - return SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL, + return SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL, fmt::format("Cannot add/remove primary label :{}", name_id_mapper_->IdToName(label))); } return std::nullopt; diff --git a/src/storage/v3/shard.cpp b/src/storage/v3/shard.cpp index bad7e8d0a..4f25916c6 100644 --- a/src/storage/v3/shard.cpp +++ b/src/storage/v3/shard.cpp @@ -364,7 +364,7 @@ ShardResult Shard::Accessor::CreateVertexAndValidate( VertexAccessor vertex_acc{&it->vertex, transaction_, &shard_->indices_, config_, shard_->vertex_validator_}; if (!inserted) { - return SHARD_ERROR(common::ErrorCode::VERTEX_ALREADY_INSERTED); + return SHARD_ERROR(ErrorCode::VERTEX_ALREADY_INSERTED); } MG_ASSERT(it != acc.end(), "Invalid Vertex accessor!"); @@ -401,14 +401,13 @@ ShardResult> Shard::Accessor::DeleteVertex(VertexA "accessor when deleting a vertex!"); auto *vertex_ptr = vertex->vertex_; - if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); if (vertex_ptr->deleted) { return std::optional{}; } - if (!vertex_ptr->in_edges.empty() || !vertex_ptr->out_edges.empty()) - return SHARD_ERROR(common::ErrorCode::VERTEX_HAS_EDGES); + if (!vertex_ptr->in_edges.empty() || !vertex_ptr->out_edges.empty()) return SHARD_ERROR(ErrorCode::VERTEX_HAS_EDGES); CreateAndLinkDelta(transaction_, vertex_ptr, Delta::RecreateObjectTag()); vertex_ptr->deleted = true; @@ -430,7 +429,7 @@ ShardResult>>> std::vector out_edges; { - if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); if (vertex_ptr->deleted) return std::optional{}; @@ -471,7 +470,7 @@ ShardResult>>> // vertex. Some other transaction could have modified the vertex in the // meantime if we didn't have any edges to delete. - if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_ptr)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); MG_ASSERT(!vertex_ptr->deleted, "Invalid database state!"); @@ -508,12 +507,12 @@ ShardResult Shard::Accessor::CreateEdge(VertexId from_vertex_id, V } if (from_is_local) { - if (!PrepareForWrite(transaction_, from_vertex)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); - if (from_vertex->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!PrepareForWrite(transaction_, from_vertex)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); + if (from_vertex->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); } if (to_is_local && to_vertex != from_vertex) { - if (!PrepareForWrite(transaction_, to_vertex)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); - if (to_vertex->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!PrepareForWrite(transaction_, to_vertex)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); + if (to_vertex->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); } EdgeRef edge(gid); @@ -568,13 +567,13 @@ ShardResult> Shard::Accessor::DeleteEdge(VertexId fr if (from_is_local) { if (!PrepareForWrite(transaction_, from_vertex)) { - return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); } MG_ASSERT(!from_vertex->deleted, "Invalid database state!"); } if (to_is_local && to_vertex != from_vertex) { if (!PrepareForWrite(transaction_, to_vertex)) { - return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); } MG_ASSERT(!to_vertex->deleted, "Invalid database state!"); } diff --git a/src/storage/v3/vertex_accessor.cpp b/src/storage/v3/vertex_accessor.cpp index 88f9aa965..6949c08cc 100644 --- a/src/storage/v3/vertex_accessor.cpp +++ b/src/storage/v3/vertex_accessor.cpp @@ -83,9 +83,9 @@ bool VertexAccessor::IsVisible(View view) const { ShardResult VertexAccessor::AddLabel(LabelId label) { utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; - if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); if (std::find(vertex_->labels.begin(), vertex_->labels.end(), label) != vertex_->labels.end()) return false; @@ -104,9 +104,9 @@ ShardResult VertexAccessor::AddLabelAndValidate(LabelId label) { } utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; - if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); if (std::find(vertex_->labels.begin(), vertex_->labels.end(), label) != vertex_->labels.end()) return false; @@ -120,9 +120,9 @@ ShardResult VertexAccessor::AddLabelAndValidate(LabelId label) { } ShardResult VertexAccessor::RemoveLabel(LabelId label) { - if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); auto it = std::find(vertex_->labels.begin(), vertex_->labels.end(), label); if (it == vertex_->labels.end()) return false; @@ -139,9 +139,9 @@ ShardResult VertexAccessor::RemoveLabelAndValidate(LabelId label) { return {*maybe_violation_error}; } - if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); auto it = std::find(vertex_->labels.begin(), vertex_->labels.end(), label); if (it == vertex_->labels.end()) return false; @@ -197,8 +197,8 @@ ShardResult VertexAccessor::HasLabel(LabelId label, View view) const { break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return has_label; } @@ -267,17 +267,17 @@ ShardResult> VertexAccessor::Labels(View view) const { break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return std::move(labels); } ShardResult VertexAccessor::SetProperty(PropertyId property, const PropertyValue &value) { utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; - if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); auto current_value = vertex_->properties.GetProperty(property); // We could skip setting the value if the previous one is the same to the new @@ -323,10 +323,10 @@ ShardResult VertexAccessor::CheckVertexExistence(View view) const { } }); if (!exists) { - return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); + return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); } if (!for_deleted_ && deleted) { - return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + return SHARD_ERROR(ErrorCode::DELETED_OBJECT); } return {}; } @@ -338,11 +338,11 @@ ShardResult VertexAccessor::SetPropertyAndValidate(PropertyId pro utils::MemoryTracker::OutOfMemoryExceptionEnabler oom_exception; if (!PrepareForWrite(transaction_, vertex_)) { - return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); } if (vertex_->deleted) { - return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + return SHARD_ERROR(ErrorCode::DELETED_OBJECT); } auto current_value = vertex_->properties.GetProperty(property); @@ -361,9 +361,9 @@ ShardResult VertexAccessor::SetPropertyAndValidate(PropertyId pro } ShardResult> VertexAccessor::ClearProperties() { - if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR); + if (!PrepareForWrite(transaction_, vertex_)) return SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR); - if (vertex_->deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (vertex_->deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); auto properties = vertex_->properties.Properties(); for (const auto &property : properties) { @@ -441,8 +441,8 @@ ShardResult VertexAccessor::GetProperty(PropertyId property, View break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return std::move(value); } @@ -491,8 +491,8 @@ ShardResult> VertexAccessor::Properties(View break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return std::move(properties); } @@ -563,8 +563,8 @@ ShardResult> VertexAccessor::InEdges(View view, const break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); std::vector ret; if (in_edges.empty()) { return ret; @@ -643,8 +643,8 @@ ShardResult> VertexAccessor::OutEdges(View view, const break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); std::vector ret; if (out_edges.empty()) { return ret; @@ -690,8 +690,8 @@ ShardResult VertexAccessor::InDegree(View view) const { break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return degree; } @@ -727,8 +727,8 @@ ShardResult VertexAccessor::OutDegree(View view) const { break; } }); - if (!exists) return SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT); - if (!for_deleted_ && deleted) return SHARD_ERROR(common::ErrorCode::DELETED_OBJECT); + if (!exists) return SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT); + if (!for_deleted_ && deleted) return SHARD_ERROR(ErrorCode::DELETED_OBJECT); return degree; } diff --git a/tests/unit/storage_v3.cpp b/tests/unit/storage_v3.cpp index a214ccac6..cab463b7f 100644 --- a/tests/unit/storage_v3.cpp +++ b/tests/unit/storage_v3.cpp @@ -580,7 +580,7 @@ TEST_P(StorageV3, VertexDeleteSerializationError) { EXPECT_EQ(CountVertices(acc2, View::NEW), 1U); auto res = acc2.DeleteVertex(&*vertex); ASSERT_TRUE(res.HasError()); - ASSERT_EQ(res.GetError(), SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR)); + ASSERT_EQ(res.GetError(), SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR)); EXPECT_EQ(CountVertices(acc2, View::OLD), 1U); EXPECT_EQ(CountVertices(acc2, View::NEW), 1U); acc2.AdvanceCommand(); @@ -711,20 +711,20 @@ TEST_P(StorageV3, VertexDeleteLabel) { // Check whether label 5 exists ASSERT_FALSE(vertex->HasLabel(label5, View::OLD).GetValue()); - ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); ASSERT_EQ(vertex->Labels(View::OLD)->size(), 0); - ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); // Try to add the label { auto ret = vertex->AddLabelAndValidate(label5); - AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT)); } // Try to remove the label { auto ret = vertex->RemoveLabelAndValidate(label5); - AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT)); } acc.Abort(); @@ -779,33 +779,33 @@ TEST_P(StorageV3, VertexDeleteLabel) { // Check whether label 5 exists ASSERT_TRUE(vertex->HasLabel(label5, View::OLD).GetValue()); - ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); { auto labels = vertex->Labels(View::OLD).GetValue(); ASSERT_EQ(labels.size(), 1); ASSERT_EQ(labels[0], label5); } - ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); // Advance command acc.AdvanceCommand(); // Check whether label 5 exists - ASSERT_EQ(vertex->HasLabel(label5, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex->Labels(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->HasLabel(label5, View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->HasLabel(label5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Labels(View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Labels(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); // Try to add the label { auto ret = vertex->AddLabelAndValidate(label5); - AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT)); } // Try to remove the label { auto ret = vertex->RemoveLabelAndValidate(label5); - AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT)); } acc.Abort(); @@ -855,14 +855,14 @@ TEST_P(StorageV3, VertexDeleteProperty) { // Check whether label 5 exists ASSERT_TRUE(vertex->GetProperty(property5, View::OLD)->IsNull()); - ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); ASSERT_EQ(vertex->Properties(View::OLD)->size(), 0); - ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); // Try to set the property5 { auto ret = vertex->SetPropertyAndValidate(property5, PropertyValue("haihai")); - AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT)); } acc.Abort(); @@ -918,27 +918,27 @@ TEST_P(StorageV3, VertexDeleteProperty) { // Check whether property 5 exists ASSERT_EQ(vertex->GetProperty(property5, View::OLD)->ValueString(), "nandare"); - ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); { auto properties = vertex->Properties(View::OLD).GetValue(); ASSERT_EQ(properties.size(), 1); ASSERT_EQ(properties[property5].ValueString(), "nandare"); } - ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); // Advance command acc.AdvanceCommand(); // Check whether property 5 exists - ASSERT_EQ(vertex->GetProperty(property5, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex->Properties(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->GetProperty(property5, View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->GetProperty(property5, View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Properties(View::OLD).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex->Properties(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); // Try to set the property { auto ret = vertex->SetPropertyAndValidate(property5, PropertyValue("haihai")); - AssertShardErrorEqual(ret, SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + AssertShardErrorEqual(ret, SHARD_ERROR(ErrorCode::DELETED_OBJECT)); } acc.Abort(); @@ -1371,7 +1371,7 @@ TEST_P(StorageV3, VertexLabelSerializationError) { { auto res = vertex->AddLabelAndValidate(label1); - AssertShardErrorEqual(res, SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR)); + AssertShardErrorEqual(res, SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR)); } } @@ -1865,7 +1865,7 @@ TEST_P(StorageV3, VertexPropertySerializationError) { { auto res = vertex->SetPropertyAndValidate(property2, PropertyValue("nandare")); - AssertShardErrorEqual(res, SHARD_ERROR(common::ErrorCode::SERIALIZATION_ERROR)); + AssertShardErrorEqual(res, SHARD_ERROR(ErrorCode::SERIALIZATION_ERROR)); } } @@ -2255,14 +2255,14 @@ TEST_P(StorageV3, VertexNonexistentLabelPropertyEdgeAPI) { auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{0}, {}); // Check state before (OLD view). - ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); // Check state before (NEW view). ASSERT_EQ(vertex.Labels(View::NEW)->size(), 0); @@ -2282,14 +2282,14 @@ TEST_P(StorageV3, VertexNonexistentLabelPropertyEdgeAPI) { .HasValue()); // Check state after (OLD view). - ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); - ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.Labels(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.HasLabel(label1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.Properties(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.GetProperty(property1, View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.InEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.OutEdges(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.InDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); + ASSERT_EQ(vertex.OutDegree(View::OLD).GetError(), SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); // Check state after (NEW view). ASSERT_EQ(vertex.Labels(View::NEW)->size(), 1); @@ -2663,25 +2663,25 @@ TEST_P(StorageV3, TestCreateVertexAndValidate) { auto acc = store.Access(GetNextHlc()); auto vertex = acc.CreateVertexAndValidate({primary_label}, {PropertyValue{0}}, {}); ASSERT_TRUE(vertex.HasError()); - EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); + EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); } { auto acc = store.Access(GetNextHlc()); auto vertex = acc.CreateVertexAndValidate({primary_label}, {PropertyValue{0}}, {}); ASSERT_TRUE(vertex.HasError()); - EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); + EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); } { auto acc = store.Access(GetNextHlc()); auto vertex = acc.CreateVertexAndValidate({}, {}, {}); ASSERT_TRUE(vertex.HasError()); - EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED)); + EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED)); } { auto acc = store.Access(GetNextHlc()); auto vertex = acc.CreateVertexAndValidate({}, {PropertyValue{"test"}}, {}); ASSERT_TRUE(vertex.HasError()); - EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); + EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); } } } // namespace memgraph::storage::v3::tests diff --git a/tests/unit/storage_v3_edge.cpp b/tests/unit/storage_v3_edge.cpp index 47327ca3e..64f7f4e2e 100644 --- a/tests/unit/storage_v3_edge.cpp +++ b/tests/unit/storage_v3_edge.cpp @@ -3242,7 +3242,7 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { { auto ret = acc.DeleteVertex(&vertex_from.value()); ASSERT_TRUE(ret.HasError()); - ASSERT_EQ(ret.GetError(), SHARD_ERROR(common::ErrorCode::VERTEX_HAS_EDGES)); + ASSERT_EQ(ret.GetError(), SHARD_ERROR(ErrorCode::VERTEX_HAS_EDGES)); } // Detach delete vertex @@ -3255,8 +3255,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { // Check edges ASSERT_EQ(vertex_from->InEdges(View::OLD)->size(), 0); ASSERT_EQ(*vertex_from->InDegree(View::OLD), 0); - ASSERT_EQ(vertex_from->InEdges(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex_from->InDegree(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex_from->InEdges(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex_from->InDegree(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); { auto ret = vertex_from->OutEdges(View::OLD); ASSERT_TRUE(ret.HasValue()); @@ -3269,8 +3269,8 @@ TEST_P(StorageEdgeTest, VertexDetachDeleteSingleCommit) { ASSERT_EQ(e.FromVertex(), from_id); ASSERT_EQ(e.ToVertex(), to_id); } - ASSERT_EQ(vertex_from->OutEdges(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); - ASSERT_EQ(vertex_from->OutDegree(View::NEW).GetError(), SHARD_ERROR(common::ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex_from->OutEdges(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); + ASSERT_EQ(vertex_from->OutDegree(View::NEW).GetError(), SHARD_ERROR(ErrorCode::DELETED_OBJECT)); { auto ret = vertex_to->InEdges(View::OLD); ASSERT_TRUE(ret.HasValue()); diff --git a/tests/unit/storage_v3_schema.cpp b/tests/unit/storage_v3_schema.cpp index 4ce611c98..4bc920313 100644 --- a/tests/unit/storage_v3_schema.cpp +++ b/tests/unit/storage_v3_schema.cpp @@ -188,43 +188,43 @@ TEST_F(SchemaValidatorTest, TestSchemaValidateVertexCreate) { { const auto schema_violation = schema_validator.ValidateVertexCreate(NameToLabel("test"), {}, {PropertyValue(1)}); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL)); } { const auto schema_violation = schema_validator.ValidateVertexCreate(label2, {}, {}); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED)); } // Validate wrong secondary label { const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {label1}, {PropertyValue("test")}); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); } { const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {label2}, {PropertyValue("test")}); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); } // Validate wrong property type { const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {}, {PropertyValue(1)}); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); } { const auto schema_violation = schema_validator.ValidateVertexCreate(label2, {}, {PropertyValue("test"), PropertyValue(12), PropertyValue(1)}); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); } { const auto wrong_prop = PropertyValue(TemporalData(TemporalType::Date, 1234)); const auto schema_violation = schema_validator.ValidateVertexCreate(label2, {}, {PropertyValue("test"), PropertyValue(12), wrong_prop}); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); } // Passing validations EXPECT_EQ(schema_validator.ValidateVertexCreate(label1, {}, {PropertyValue("test")}), std::nullopt); @@ -246,12 +246,12 @@ TEST_F(SchemaValidatorTest, TestSchemaValidatePropertyUpdate) { { const auto schema_violation = schema_validator.ValidatePropertyUpdate(label1, prop_string); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); } { const auto schema_violation = schema_validator.ValidatePropertyUpdate(label2, prop_duration); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); } EXPECT_EQ(schema_validator.ValidatePropertyUpdate(label1, prop_int), std::nullopt); EXPECT_EQ(schema_validator.ValidatePropertyUpdate(label1, prop_duration), std::nullopt); @@ -263,12 +263,12 @@ TEST_F(SchemaValidatorTest, TestSchemaValidatePropertyUpdateLabel) { { const auto schema_violation = schema_validator.ValidateLabelUpdate(label1); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); } { const auto schema_violation = schema_validator.ValidateLabelUpdate(label2); ASSERT_NE(schema_violation, std::nullopt); - EXPECT_EQ(*schema_violation, SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); + EXPECT_EQ(*schema_violation, SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); } EXPECT_EQ(schema_validator.ValidateLabelUpdate(NameToLabel("test")), std::nullopt); } diff --git a/tests/unit/storage_v3_vertex_accessors.cpp b/tests/unit/storage_v3_vertex_accessors.cpp index dd515983a..9a155efb4 100644 --- a/tests/unit/storage_v3_vertex_accessors.cpp +++ b/tests/unit/storage_v3_vertex_accessors.cpp @@ -77,7 +77,7 @@ TEST_F(StorageV3Accessor, TestPrimaryLabel) { ASSERT_TRUE(vertex.PrimaryLabel(View::OLD).HasError()); const auto error_primary_label = vertex.PrimaryLabel(View::OLD).GetError(); ASSERT_FALSE(vertex.PrimaryLabel(View::NEW).HasError()); - EXPECT_EQ(error_primary_label, SHARD_ERROR(common::ErrorCode::NONEXISTENT_OBJECT)); + EXPECT_EQ(error_primary_label, SHARD_ERROR(ErrorCode::NONEXISTENT_OBJECT)); } { auto acc = storage.Access(GetNextHlc()); @@ -128,7 +128,7 @@ TEST_F(StorageV3Accessor, TestAddLabels) { const auto label1 = NameToLabelId("label"); auto vertex = acc.CreateVertexAndValidate({label1}, {PropertyValue{2}}, {}); ASSERT_TRUE(vertex.HasError()); - EXPECT_EQ(vertex.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); + EXPECT_EQ(vertex.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); } { auto acc = storage.Access(GetNextHlc()); @@ -137,7 +137,7 @@ TEST_F(StorageV3Accessor, TestAddLabels) { ASSERT_TRUE(vertex.HasValue()); const auto schema_violation = vertex->AddLabelAndValidate(label1); ASSERT_TRUE(schema_violation.HasError()); - EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); + EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); } } @@ -181,7 +181,7 @@ TEST_F(StorageV3Accessor, TestRemoveLabels) { auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{2}); const auto res1 = vertex.RemoveLabelAndValidate(primary_label); ASSERT_TRUE(res1.HasError()); - EXPECT_EQ(res1.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); + EXPECT_EQ(res1.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); } } @@ -200,14 +200,14 @@ TEST_F(StorageV3Accessor, TestSetKeysAndProperties) { auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{1}); const auto res = vertex.SetPropertyAndValidate(primary_property, PropertyValue(1)); ASSERT_TRUE(res.HasError()); - EXPECT_EQ(res.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); + EXPECT_EQ(res.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); } { auto acc = storage.Access(GetNextHlc()); auto vertex = CreateVertexAndValidate(acc, {}, PropertyValue{2}); const auto res = vertex.SetPropertyAndValidate(primary_property, PropertyValue()); ASSERT_TRUE(res.HasError()); - EXPECT_EQ(res.GetError(), SHARD_ERROR(common::ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); + EXPECT_EQ(res.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); } }