From 04d44a2d9a4fc377a89b260ffc30f90d21b40b53 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Mon, 2 Aug 2021 12:15:01 +0200 Subject: [PATCH] EHN: also add warnings and info messages from IdResponse to entity --- src/caosdb/configuration.cpp | 2 +- src/caosdb/entity.cpp | 3 +++ test/test_entity.cpp | 14 +++++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/caosdb/configuration.cpp b/src/caosdb/configuration.cpp index 6cdd04c..b5465cd 100644 --- a/src/caosdb/configuration.cpp +++ b/src/caosdb/configuration.cpp @@ -468,7 +468,7 @@ auto ConfigurationManager::InitializeDefaults() -> int { // NOLINT // find the configuration file... std::unique_ptr<path> configuration_file_path; - for (const char* const &configuration_file : + for (const char *const &configuration_file : caosdb::LIBCAOSDB_CONFIGURATION_FILES_PRECEDENCE) { if (strcmp(configuration_file, "$CAOSDB_CLIENT_CONFIGURATION") == 0) { // user specified a file via the environment variable diff --git a/src/caosdb/entity.cpp b/src/caosdb/entity.cpp index 0ef5172..24fd382 100644 --- a/src/caosdb/entity.cpp +++ b/src/caosdb/entity.cpp @@ -80,6 +80,9 @@ Entity::Entity() : wrapped(Entity::CreateProtoEntity()) { Entity::Entity(IdResponse *idResponse) : Entity() { this->wrapped->set_id(idResponse->id()); this->wrapped->mutable_errors()->Swap(idResponse->mutable_entity_errors()); + this->wrapped->mutable_warnings()->Swap( + idResponse->mutable_entity_warnings()); + this->wrapped->mutable_infos()->Swap(idResponse->mutable_entity_infos()); } auto Entity::SetId(const std::string &id) -> void { this->wrapped->set_id(id); } diff --git a/test/test_entity.cpp b/test/test_entity.cpp index e34e073..1f3adf9 100644 --- a/test/test_entity.cpp +++ b/test/test_entity.cpp @@ -101,14 +101,14 @@ TEST(test_entity, test_from_id_response) { // NOLINT Entity other_ent(&idr_warnings_and_infos); - EXPECT_EQ(entity.GetId(), "other_entity_id"); - EXPECT_EQ(entity.GetWarnings().Size(), 1); - EXPECT_EQ(entity.GetWarnings().At(0).GetDescription(), "warning_desc"); - EXPECT_EQ(entity.GetWarnings().At(0).GetCode(), + EXPECT_EQ(other_ent.GetId(), "other_entity_id"); + EXPECT_EQ(other_ent.GetWarnings().Size(), 1); + EXPECT_EQ(other_ent.GetWarnings().At(0).GetDescription(), "warning_desc"); + EXPECT_EQ(other_ent.GetWarnings().At(0).GetCode(), MessageCode::ENTITY_HAS_NO_PROPERTIES); - EXPECT_EQ(entity.GetInfos().Size(), 1); - EXPECT_EQ(entity.GetInfos().At(0).GetDescription(), "info_desc"); - EXPECT_EQ(entity.GetInfos().At(0).GetCode(), MessageCode::UNSPECIFIED); + EXPECT_EQ(other_ent.GetInfos().Size(), 1); + EXPECT_EQ(other_ent.GetInfos().At(0).GetDescription(), "info_desc"); + EXPECT_EQ(other_ent.GetInfos().At(0).GetCode(), MessageCode::UNSPECIFIED); } } // namespace caosdb::entity -- GitLab