diff --git a/src/storage/v3/shard_rsm.cpp b/src/storage/v3/shard_rsm.cpp index 62f46b944..a027140e2 100644 --- a/src/storage/v3/shard_rsm.cpp +++ b/src/storage/v3/shard_rsm.cpp @@ -805,7 +805,7 @@ msgs::ReadResponses ShardRsm::HandleRead(msgs::ScanVerticesRequest &&req) { } msgs::ScanVerticesResponse resp{.error = std::move(shard_error)}; - if (resp.error) { + if (!resp.error) { resp.next_start_id = next_start_id; resp.results = std::move(results); } diff --git a/tests/simulation/shard_rsm.cpp b/tests/simulation/shard_rsm.cpp index b9511f024..b197f114d 100644 --- a/tests/simulation/shard_rsm.cpp +++ b/tests/simulation/shard_rsm.cpp @@ -156,7 +156,7 @@ bool AttemptToCreateVertex(ShardClient &client, int64_t value) { create_req.transaction_id.logical_id = GetTransactionId(); auto write_res = client.SendWriteRequest(create_req); - MG_ASSERT(write_res.HasValue() && std::get(write_res.GetValue()).error, + MG_ASSERT(write_res.HasValue() && !std::get(write_res.GetValue()).error.has_value(), "Unexpected failure"); Commit(client, create_req.transaction_id); diff --git a/tests/unit/machine_manager.cpp b/tests/unit/machine_manager.cpp index 7b57d61ea..110220eda 100644 --- a/tests/unit/machine_manager.cpp +++ b/tests/unit/machine_manager.cpp @@ -131,6 +131,7 @@ void TestCreateVertices(msgs::ShardRequestManagerInterface &shard_request_manage auto result = shard_request_manager.Request(state, std::move(new_vertices)); EXPECT_EQ(result.size(), 1); + EXPECT_FALSE(result[0].error.has_value()) << result[0].error->message; } void TestCreateExpand(msgs::ShardRequestManagerInterface &shard_request_manager) { diff --git a/tests/unit/storage_v3_schema.cpp b/tests/unit/storage_v3_schema.cpp index 2c5515958..df84fd70c 100644 --- a/tests/unit/storage_v3_schema.cpp +++ b/tests/unit/storage_v3_schema.cpp @@ -186,43 +186,43 @@ TEST_F(SchemaValidatorTest, TestSchemaValidateVertexCreate) { // Validate against secondary label { const auto schema_violation = schema_validator.ValidateVertexCreate(NameToLabel("test"), {}, {PropertyValue(1)}); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_NO_SCHEMA_DEFINED_FOR_LABEL)); } { const auto schema_violation = schema_validator.ValidateVertexCreate(label2, {}, {}); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PRIMARY_PROPERTIES_UNDEFINED)); } // Validate wrong secondary label { const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {label1}, {PropertyValue("test")}); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); } { const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {label2}, {PropertyValue("test")}); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_SECONDARY_LABEL_IS_PRIMARY)); } // Validate wrong property type { const auto schema_violation = schema_validator.ValidateVertexCreate(label1, {}, {PropertyValue(1)}); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); } { const auto schema_violation = schema_validator.ValidateVertexCreate(label2, {}, {PropertyValue("test"), PropertyValue(12), PropertyValue(1)}); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), 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_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_PROPERTY_WRONG_TYPE)); } // Passing validations @@ -247,12 +247,12 @@ TEST_F(SchemaValidatorTest, TestSchemaValidatePropertyUpdate) { // Validate updating of primary key { const auto schema_violation = schema_validator.ValidatePropertyUpdate(label1, prop_string); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); } { const auto schema_violation = schema_validator.ValidatePropertyUpdate(label2, prop_duration); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_KEY)); } EXPECT_FALSE(schema_validator.ValidatePropertyUpdate(label1, prop_int).HasError()); @@ -264,12 +264,12 @@ TEST_F(SchemaValidatorTest, TestSchemaValidatePropertyUpdateLabel) { // Validate adding primary label { const auto schema_violation = schema_validator.ValidateLabelUpdate(label1); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); } { const auto schema_violation = schema_validator.ValidateLabelUpdate(label2); - ASSERT_FALSE(schema_violation.HasError()); + ASSERT_TRUE(schema_violation.HasError()); EXPECT_EQ(schema_violation.GetError(), SHARD_ERROR(ErrorCode::SCHEMA_VERTEX_UPDATE_PRIMARY_LABEL)); } EXPECT_FALSE(schema_validator.ValidateLabelUpdate(NameToLabel("test")).HasError());