Skip to content
Snippets Groups Projects
Commit 681d060f authored by florian's avatar florian
Browse files

WIP: Warnings

parent 8d56a257
No related branches found
No related tags found
1 merge request!4ENH: Allow insertion and deletion of single entities
Pipeline #10980 failed
......@@ -317,9 +317,10 @@ public:
[[nodiscard]] inline auto HasErrors() const -> bool {
return this->errors.wrapped->size() > 0;
}
// TODO(fspreck) These two need implementations...
[[nodiscard]] auto GetWarnings() const -> const Messages &;
[[nodiscard]] auto GetInfos() const -> const Messages &;
[[nodiscard]] auto GetWarnings() const -> const Messages & {
return warnings;
}
[[nodiscard]] auto GetInfos() const -> const Messages & { return infos; }
inline auto ToString() const -> const std::string {
google::protobuf::util::JsonOptions options;
......
......@@ -463,7 +463,8 @@ auto ConfigurationManager::GetConnection(const std::string &name) const
"' has not been defined.");
}
auto ConfigurationManager::InitializeDefaults() -> int {
// TODO(tf) This has apparently a cognitive complexity of 34>25 (threshold).
auto ConfigurationManager::InitializeDefaults() -> int { // NOLINT
// find the configuration file...
std::unique_ptr<path> configuration_file_path;
......@@ -471,7 +472,8 @@ auto ConfigurationManager::InitializeDefaults() -> int {
caosdb::LIBCAOSDB_CONFIGURATION_FILES_PRECEDENCE) {
if (configuration_file == "$CAOSDB_CLIENT_CONFIGURATION") {
// user specified a file via the environment variable
const auto *from_env_var = getenv("CAOSDB_CLIENT_CONFIGURATION");
// TODO(tf) make this thread-secure (concurrency-mt-unsafe)
const auto *from_env_var = getenv("CAOSDB_CLIENT_CONFIGURATION"); // NOLINT
if (from_env_var != nullptr) {
configuration_file_path = std::make_unique<path>(from_env_var);
if (exists(*configuration_file_path)) {
......
......@@ -88,6 +88,26 @@ TEST(test_entity, test_from_id_response) {
EXPECT_EQ(entity.GetErrors().At(0).GetDescription(), "error_desc");
EXPECT_EQ(entity.GetErrors().At(0).GetCode(),
MessageCode::ENTITY_DOES_NOT_EXIST);
IdResponse idr_warnings_and_infos;
idr_warnings_and_infos.set_id("other_entity_id");
auto *warning = idr_warnings_and_infos.add_entity_warnings();
warning->set_description("warning_desc");
warning->set_code(MessageCode::ENTITY_HAS_NO_PROPERTIES);
auto *info = idr_warnings_and_infos.add_entity_infos();
info->set_description("info_desc");
info->set_code(MessageCode::UNSPECIFIED);
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(),
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);
}
} // namespace caosdb::entity
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment