From dfdce3379bd6e5c87879844b37674e9fc384c6ff Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Tue, 3 Aug 2021 12:18:17 +0200 Subject: [PATCH] DRAFT: Add test for inserting with a parent --- test/test_entity.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/test_entity.cpp b/test/test_entity.cpp index 66423eb..60177fb 100644 --- a/test/test_entity.cpp +++ b/test/test_entity.cpp @@ -98,6 +98,31 @@ TEST(test_entity, test_insert_with_role) { // NOLINT EXPECT_EQ(entity.GetValue(), "5.5"); } +TEST(test_entity, test_insert_with_parent) { + auto transaction = caosdb::transaction::Transaction( + std::shared_ptr<transaction::EntityTransactionService::Stub>(nullptr)); + + auto entity = Entity(); + entity.SetId("entity_id"); + + auto parent = Parent(); + parent.SetId("parent_id"); + parent.SetName("parent_name"); + EXPECT_EQ(parent.GetId(), "parent_id"); + EXPECT_EQ(parent.GetName(), "parent_name"); + + entity.AppendParent(parent); + + transaction.InsertEntity(&entity); + + std::cout << entity.ToString() << std::endl; + EXPECT_EQ(entity.GetId(), "entity_id"); + EXPECT_EQ(entity.GetParents().Size(), 1); + auto inserted_parent = entity.GetParents().At(0); + EXPECT_EQ(inserted_parent.GetId(), parent.GetId()); + EXPECT_EQ(inserted_parent.GetName(), parent.GetName()); +} + // TODO(tf) cognitive complexity > 25 (threshold) TEST(test_entity, test_from_id_response) { // NOLINT IdResponse idResponse; -- GitLab