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

WIP: insert delete

parent 307e21b4
No related branches found
No related tags found
1 merge request!4ENH: Allow insertion and deletion of single entities
Pipeline #10860 failed
......@@ -41,7 +41,7 @@ enum MessageCode {
caosdb::entity::v1alpha1::MessageCode::MESSAGE_CODE_ENTITY_DOES_NOT_EXIST,
};
[[nodiscard]] inline auto get_message_code(int code) -> MessageCode {
[[nodiscard]] inline auto get_message_code(int code) noexcept -> MessageCode {
// TODO(tf) smarter, less forgot-it-prone implementation
static MessageCode all_codes[] = {
MessageCode::UNSPECIFIED,
......
......@@ -22,13 +22,14 @@
#include "caosdb/entity.h" // for Entity, Parent, Par...
#include "caosdb/entity/v1alpha1/main.grpc.pb.h" // for EntityTransactionSe...
#include "caosdb/entity/v1alpha1/main.pb.h" // for IdResponse, Message
#include "caosdb/transaction.h" // for Transaction
#include "gtest/gtest-message.h" // for Message
#include "gtest/gtest-test-part.h" // for TestPartResult, Sui...
#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ
#include <iostream> // for endl, basic_ostream
#include <memory> // for allocator, shared_ptr
#include <string> // for operator<<
#include "caosdb/message_code.h"
#include "caosdb/transaction.h" // for Transaction
#include "gtest/gtest-message.h" // for Message
#include "gtest/gtest-test-part.h" // for TestPartResult, Sui...
#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ
#include <iostream> // for endl, basic_ostream
#include <memory> // for allocator, shared_ptr
#include <string> // for operator<<
namespace caosdb::entity {
using caosdb::entity::v1alpha1::IdResponse;
......@@ -76,7 +77,7 @@ TEST(test_entity, test_from_id_response) {
IdResponse idResponse;
idResponse.set_id("entity_id");
auto *error = idResponse.add_entity_errors();
error->set_code(1234);
error->set_code(MessageCode::ENTITY_DOES_NOT_EXIST);
error->set_description("error_desc");
Entity entity(&idResponse);
......@@ -85,8 +86,8 @@ TEST(test_entity, test_from_id_response) {
EXPECT_EQ(entity.GetId(), "entity_id");
EXPECT_EQ(entity.GetErrors().Size(), 1);
EXPECT_EQ(entity.GetErrors().At(0).GetDescription(), "error_desc");
EXPECT_EQ(entity.GetErrors().At(0).GetDescription(), "wrong");
EXPECT_EQ(entity.GetErrors().At(0).GetCode(), 1234);
EXPECT_EQ(entity.GetErrors().At(0).GetCode(),
MessageCode::ENTITY_DOES_NOT_EXIST);
}
} // 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