Skip to content
Snippets Groups Projects

F consolidation

Merged Henrik tom Wörden requested to merge f-consolidation into dev
1 file
+ 29
11
Compare changes
  • Side-by-side
  • Inline
+ 29
11
@@ -57,6 +57,7 @@ protected:
test_upload_file_1 = fs::path("test_upload_file_1_delete_me.dat");
test_download_file_1 = fs::path("test_download_file_1_delete_me.dat");
// fill the file that shall be uploaded
FileWriter writer(test_upload_file_1);
std::string buffer(1024, 'c');
for (int i = 0; i < 8; i++) {
@@ -65,11 +66,13 @@ protected:
}
void TearDown() override {
// delete files
fs::remove(test_upload_file_1);
fs::remove(test_download_file_1);
// delete all entities
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
caosdb::connection::ConnectionManager::GetDefaultConnection();
auto query_transaction(connection->CreateTransaction());
query_transaction->Query("FIND ENTITY WITH id > 99");
query_transaction->Execute();
@@ -83,9 +86,15 @@ protected:
}
};
/*
* Test the retrieval of a non-existing entity
*
* The transaction returns an error code and the entity has the appropriate
* error message
*/
TEST_F(test_transaction, retrieve_non_existing) {
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
caosdb::connection::ConnectionManager::GetDefaultConnection();
auto transaction(connection->CreateTransaction());
@@ -107,9 +116,15 @@ TEST_F(test_transaction, retrieve_non_existing) {
MessageCode::ENTITY_DOES_NOT_EXIST);
}
/*
* Testing the insertion of a basic entity
* Transaction should terminate without errors.
* Returned entity should have an id, no errors and a warning since no property
* is set.
*/
TEST_F(test_transaction, insert_without_delete) {
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
caosdb::connection::ConnectionManager::GetDefaultConnection();
auto insert_transaction(connection->CreateTransaction());
@@ -136,9 +151,15 @@ TEST_F(test_transaction, insert_without_delete) {
MessageCode::ENTITY_HAS_NO_PROPERTIES);
}
/*
* Test deletion of an entity
* Insert an entity first.
*/
TEST_F(test_transaction, insert_delete) {
// same as in insert_without_delete
// until marked END SAME
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
caosdb::connection::ConnectionManager::GetDefaultConnection();
auto insert_transaction(connection->CreateTransaction());
@@ -157,12 +178,7 @@ TEST_F(test_transaction, insert_delete) {
const auto &new_entity = insert_result_set.at(0);
EXPECT_FALSE(new_entity.GetId().empty());
EXPECT_FALSE(new_entity.HasErrors());
// Should have a warning since it has no properties
EXPECT_TRUE(new_entity.HasWarnings());
EXPECT_EQ(new_entity.GetWarnings().size(), 1);
EXPECT_EQ(new_entity.GetWarnings().at(0).GetCode(),
MessageCode::ENTITY_HAS_NO_PROPERTIES);
// END SAME
auto delete_transaction(connection->CreateTransaction());
@@ -183,10 +199,11 @@ TEST_F(test_transaction, insert_delete) {
TEST_F(test_transaction, insert_delete_with_parent) {
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
caosdb::connection::ConnectionManager::GetDefaultConnection();
auto insert_transaction(connection->CreateTransaction());
// insert RT
Entity rt;
rt.SetRole(Role::RECORD_TYPE);
rt.SetName("TestRT");
@@ -202,6 +219,7 @@ TEST_F(test_transaction, insert_delete_with_parent) {
const auto &inserted_rt = insert_result_set.at(0);
// insert Record with parent
Entity rec;
rec.SetRole(Role::RECORD);
rec.SetName("TestRec");
Loading