Skip to content
Snippets Groups Projects
Verified Commit 8f115afb authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-insert' into f-multi-retrieve

parents bd0d93fd 04d44a2d
No related branches found
No related tags found
1 merge request!5F multi retrieve
Pipeline #11074 failed
...@@ -319,9 +319,10 @@ public: ...@@ -319,9 +319,10 @@ public:
[[nodiscard]] inline auto HasErrors() const -> bool { [[nodiscard]] inline auto HasErrors() const -> bool {
return this->errors.wrapped->size() > 0; return this->errors.wrapped->size() > 0;
} }
// TODO(fspreck) These two need implementations... [[nodiscard]] auto GetWarnings() const -> const Messages & {
[[nodiscard]] auto GetWarnings() const -> const Messages &; return warnings;
[[nodiscard]] auto GetInfos() const -> const Messages &; }
[[nodiscard]] auto GetInfos() const -> const Messages & { return infos; }
inline auto ToString() const -> const std::string { inline auto ToString() const -> const std::string {
google::protobuf::util::JsonOptions options; google::protobuf::util::JsonOptions options;
......
...@@ -64,9 +64,11 @@ public: ...@@ -64,9 +64,11 @@ public:
* @brief The transaction terminated unsuccessfully. * @brief The transaction terminated unsuccessfully.
*/ */
class TransactionError : public Exception { class TransactionError : public Exception {
public: protected:
TransactionError(StatusCode code, const std::string &what_arg) TransactionError(StatusCode code, const std::string &what_arg)
: Exception(code, what_arg) {} : Exception(code, what_arg) {}
public:
explicit TransactionError(const std::string &what_arg) explicit TransactionError(const std::string &what_arg)
: Exception(StatusCode::GENERIC_TRANSACTION_ERROR, what_arg) {} : Exception(StatusCode::GENERIC_TRANSACTION_ERROR, what_arg) {}
}; };
......
...@@ -463,15 +463,18 @@ auto ConfigurationManager::GetConnection(const std::string &name) const ...@@ -463,15 +463,18 @@ auto ConfigurationManager::GetConnection(const std::string &name) const
"' has not been defined."); "' 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... // find the configuration file...
std::unique_ptr<path> configuration_file_path; std::unique_ptr<path> configuration_file_path;
for (const std::string &configuration_file : for (const char *const &configuration_file :
caosdb::LIBCAOSDB_CONFIGURATION_FILES_PRECEDENCE) { caosdb::LIBCAOSDB_CONFIGURATION_FILES_PRECEDENCE) {
if (configuration_file == "$CAOSDB_CLIENT_CONFIGURATION") { if (strcmp(configuration_file, "$CAOSDB_CLIENT_CONFIGURATION") == 0) {
// user specified a file via the environment variable // 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) { if (from_env_var != nullptr) {
configuration_file_path = std::make_unique<path>(from_env_var); configuration_file_path = std::make_unique<path>(from_env_var);
if (exists(*configuration_file_path)) { if (exists(*configuration_file_path)) {
......
...@@ -80,6 +80,9 @@ Entity::Entity() : wrapped(Entity::CreateProtoEntity()) { ...@@ -80,6 +80,9 @@ Entity::Entity() : wrapped(Entity::CreateProtoEntity()) {
Entity::Entity(IdResponse *idResponse) : Entity() { Entity::Entity(IdResponse *idResponse) : Entity() {
this->wrapped->set_id(idResponse->id()); this->wrapped->set_id(idResponse->id());
this->wrapped->mutable_errors()->Swap(idResponse->mutable_entity_errors()); 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); } auto Entity::SetId(const std::string &id) -> void { this->wrapped->set_id(id); }
......
...@@ -38,7 +38,8 @@ protected: ...@@ -38,7 +38,8 @@ protected:
void TearDown() override { ConfigurationManager::Clear(); } void TearDown() override { ConfigurationManager::Clear(); }
}; };
TEST_F(test_configuration, load_json) { // TODO(tf) cogintive complexity > 25 (threshold)
TEST_F(test_configuration, load_json) { // NOLINT
ConfigurationManager::LoadSingleJSONConfiguration(TEST_DATA_DIR + ConfigurationManager::LoadSingleJSONConfiguration(TEST_DATA_DIR +
"/test_caosdb_client.json"); "/test_caosdb_client.json");
EXPECT_THROW_MESSAGE( EXPECT_THROW_MESSAGE(
...@@ -52,7 +53,9 @@ TEST_F(test_configuration, load_json) { ...@@ -52,7 +53,9 @@ TEST_F(test_configuration, load_json) {
ConfigurationManager::Clear(); ConfigurationManager::Clear();
} }
TEST_F(test_configuration, get_default_connection_configuration_error) { // TODO(tf) cognitive complexity again
TEST_F(test_configuration, // NOLINT
get_default_connection_configuration_error) { // NOLINT
EXPECT_THROW_MESSAGE(ConfigurationManager::GetDefaultConnectionName(), EXPECT_THROW_MESSAGE(ConfigurationManager::GetDefaultConnectionName(),
ConfigurationError, ConfigurationError,
"This CaosDB client has not been configured."); "This CaosDB client has not been configured.");
......
...@@ -65,7 +65,8 @@ TEST_F(test_connection, configure_ssl_localhost_8080) { ...@@ -65,7 +65,8 @@ TEST_F(test_connection, configure_ssl_localhost_8080) {
EXPECT_TRUE(sslcc != nullptr); EXPECT_TRUE(sslcc != nullptr);
} }
TEST_F(test_connection, connection_manager_unknown_connection) { // TODO(tf) cognitive complexity > 25 (threshold)
TEST_F(test_connection, connection_manager_unknown_connection) { // NOLINT
EXPECT_THROW_MESSAGE(ConnectionManager::GetConnection("test"), EXPECT_THROW_MESSAGE(ConnectionManager::GetConnection("test"),
caosdb::exceptions::UnknownConnectionError, caosdb::exceptions::UnknownConnectionError,
"No connection named 'test' present."); "No connection named 'test' present.");
......
...@@ -73,7 +73,8 @@ TEST(test_entity, test_insert_entity) { ...@@ -73,7 +73,8 @@ TEST(test_entity, test_insert_entity) {
EXPECT_EQ(entity.GetVersionId(), "version_id"); EXPECT_EQ(entity.GetVersionId(), "version_id");
} }
TEST(test_entity, test_from_id_response) { // TODO(tf) cognitive complexity > 25 (threshold)
TEST(test_entity, test_from_id_response) { // NOLINT
IdResponse idResponse; IdResponse idResponse;
idResponse.set_id("entity_id"); idResponse.set_id("entity_id");
auto *error = idResponse.add_entity_errors(); auto *error = idResponse.add_entity_errors();
...@@ -88,6 +89,26 @@ TEST(test_entity, test_from_id_response) { ...@@ -88,6 +89,26 @@ TEST(test_entity, test_from_id_response) {
EXPECT_EQ(entity.GetErrors().At(0).GetDescription(), "error_desc"); EXPECT_EQ(entity.GetErrors().At(0).GetDescription(), "error_desc");
EXPECT_EQ(entity.GetErrors().At(0).GetCode(), EXPECT_EQ(entity.GetErrors().At(0).GetCode(),
MessageCode::ENTITY_DOES_NOT_EXIST); 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(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(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 } // namespace caosdb::entity
...@@ -29,7 +29,8 @@ namespace caosdb { ...@@ -29,7 +29,8 @@ namespace caosdb {
using caosdb::entity::v1alpha1::Entity; using caosdb::entity::v1alpha1::Entity;
using caosdb::entity::v1alpha1::Message; using caosdb::entity::v1alpha1::Message;
TEST(test_protobuf, test_swap_trivial) { // TODO(tf) cognitive complexity > 25 (threshold)
TEST(test_protobuf, test_swap_trivial) { // NOLINT
Message message_source; Message message_source;
message_source.set_code(1234); message_source.set_code(1234);
message_source.set_description("desc"); message_source.set_description("desc");
...@@ -49,7 +50,8 @@ TEST(test_protobuf, test_swap_trivial) { ...@@ -49,7 +50,8 @@ TEST(test_protobuf, test_swap_trivial) {
EXPECT_EQ(message_destination.description(), "desc"); EXPECT_EQ(message_destination.description(), "desc");
} }
TEST(test_protobuf, test_swap_nested) { // TODO(tf) cognitive complexity again
TEST(test_protobuf, test_swap_nested) { // NOLINT
Entity entity_source; Entity entity_source;
entity_source.set_id("entity_id"); entity_source.set_id("entity_id");
auto *version_source = entity_source.mutable_version(); auto *version_source = entity_source.mutable_version();
......
...@@ -41,7 +41,8 @@ using caosdb::exceptions::ConnectionError; ...@@ -41,7 +41,8 @@ using caosdb::exceptions::ConnectionError;
using caosdb::transaction::UniqueResult; using caosdb::transaction::UniqueResult;
using ProtoEntity = caosdb::entity::v1alpha1::Entity; using ProtoEntity = caosdb::entity::v1alpha1::Entity;
TEST(test_transaction, create_transaction) { // TODO(tf) cognitive complexity > 25 (threshold)
TEST(test_transaction, create_transaction) { // NOLINT
const auto *host = "localhost"; const auto *host = "localhost";
auto configuration = InsecureConnectionConfiguration(host, 8000); auto configuration = InsecureConnectionConfiguration(host, 8000);
Connection connection(configuration); Connection connection(configuration);
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
* *
*/ */
#include "gmock/gmock-matchers.h" // for ElementsAre, EXPECT_THAT
#include "boost/beast/core/detail/base64.hpp" // for encoded_size
#include "boost/json/object.hpp" // for object #include "boost/json/object.hpp" // for object
#include "boost/json/value.hpp" // for value #include "boost/json/value.hpp" // for value
#include "caosdb/utility.h" // for base64_encode, load_js... #include "caosdb/utility.h" // for base64_encode, load_js...
#include "caosdb_test_utility.h" // for TEST_DATA_DIR #include "caosdb_test_utility.h" // for TEST_DATA_DIR
#include "gmock/gmock-matchers.h" // for ElementsAre, EXPECT_THAT
#include <boost/beast/core/detail/base64.hpp> // for encoded_size
#include <gtest/gtest-message.h> // for Message #include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteA... #include <gtest/gtest-test-part.h> // for TestPartResult, SuiteA...
#include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ, TestInfo #include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ, TestInfo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment