From 6d22e2e239cf92b32cfb681ecbb5a338c4f2d7dc Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Tue, 3 Aug 2021 14:08:10 +0200
Subject: [PATCH] TST: Add another unit test

---
 test/test_entity.cpp | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/test/test_entity.cpp b/test/test_entity.cpp
index e1d9271..ec11796 100644
--- a/test/test_entity.cpp
+++ b/test/test_entity.cpp
@@ -201,6 +201,38 @@ TEST(test_entity, test_insert_with_parent) {
   EXPECT_EQ(inserted_parent.GetName(), parent.GetName());
 }
 
+// TODO(fspreck) cognitive complexity > 25 (threshold)
+TEST(test_entity, test_insert_with_property) { // NOLINT
+  auto transaction = caosdb::transaction::Transaction(
+    std::shared_ptr<transaction::EntityTransactionService::Stub>(nullptr));
+
+  auto entity = Entity();
+  entity.SetId("entity_id");
+
+  auto prop = Property();
+  prop.SetName("prop_name");
+  prop.SetId("prop_id");
+  prop.SetImportance("prop_importance");
+  prop.SetValue("prop_value");
+  prop.SetUnit("prop_unit");
+  prop.SetDatatype("prop_dtype");
+
+  entity.AppendProperty(prop);
+
+  transaction.InsertEntity(&entity);
+
+  EXPECT_EQ(entity.GetProperties().Size(), 1);
+
+  auto inserted_prop = entity.GetProperties().At(0);
+
+  EXPECT_EQ(prop.GetName(), inserted_prop.GetName());
+  EXPECT_EQ(prop.GetId(), inserted_prop.GetId());
+  EXPECT_EQ(prop.GetImportance(), inserted_prop.GetImportance());
+  EXPECT_EQ(prop.GetValue(), inserted_prop.GetValue());
+  EXPECT_EQ(prop.GetUnit(), inserted_prop.GetUnit());
+  EXPECT_EQ(prop.GetDatatype(), inserted_prop.GetDatatype());
+}
+
 // TODO(tf) cognitive complexity > 25 (threshold)
 TEST(test_entity, test_from_id_response) { // NOLINT
   IdResponse idResponse;
-- 
GitLab