Skip to content
Snippets Groups Projects
Commit 615a96a7 authored by florian's avatar florian
Browse files

Merge branch 'dev' into f-full-c

parents 8665598f 72cfe1d0
No related branches found
No related tags found
1 merge request!11ENH: Test insert/update/delete and files in Extern C
Pipeline #12183 passed
This commit is part of merge request !11. Comments created here will be created in the context of that merge request.
......@@ -24,6 +24,7 @@
set(test_cases
test_connection
test_transaction
#test_file_transmission TODO add once fixed
test_ccaosdb
)
......
......@@ -36,6 +36,12 @@ using caosdb::entity::v1alpha1::RegisterFileUploadResponse;
using caosdb::entity::v1alpha1::RegistrationStatus;
using caosdb::entity::v1alpha1::TransmissionStatus;
// TODO(tf) this file is currently not used (see CMakeLists.txt)
// Is it still necessary or is it obsolete due to test_transaction.cpp?
// RegisterFileDownloadResponse is currently not defined by proto or the h
// file.
class test_file_transmission : public ::testing::Test {
protected:
void SetUp() override {}
......
......@@ -20,6 +20,7 @@
*/
#include "caosdb/connection.h" // for Connection, ConnectionManager
#include "caosdb/entity.h" // for Entity, Messages, Message
#include "caosdb/file_transmission/file_reader.h" // for FileReader
#include "caosdb/file_transmission/file_writer.h" // for FileWriter
#include "caosdb/message_code.h" // for ENTITY_DOES_NOT_EXIST, Messag...
#include "caosdb/status_code.h" // for SUCCESS, StatusCode
......@@ -690,9 +691,18 @@ TEST_F(test_transaction, test_file_upload) {
const auto &inserted_file = insert_results.at(0);
EXPECT_FALSE(inserted_file.GetId().empty());
EXPECT_FALSE(inserted_file.HasErrors());
// Check file once more
auto count_query(connection->CreateTransaction());
count_query->Query("COUNT FILE WHICH IS STORED AT 'test.txt'");
count_query->ExecuteAsynchronously();
auto count_and_retrieve_status = count_query->WaitForIt();
ASSERT_TRUE(count_and_retrieve_status.IsTerminated());
ASSERT_FALSE(count_and_retrieve_status.IsError());
EXPECT_EQ(count_query->GetCountResult(), 1);
}
TEST_F(test_transaction, test_file_download) {
TEST_F(test_transaction, test_file_up_n_download) {
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
......@@ -725,6 +735,14 @@ TEST_F(test_transaction, test_file_download) {
ASSERT_FALSE(downloaded_file.HasErrors());
EXPECT_EQ(downloaded_file.GetLocalPath().string(),
test_download_file_1.string());
FileReader reader_remote(test_upload_file_1);
std::string buffer_local(1024, 'c');
std::string buffer_remote(1024, 'c');
for (int i = 0; i < 8; i++) {
reader_remote.read(buffer_remote);
EXPECT_EQ(buffer_remote, buffer_local);
}
}
} // namespace caosdb::transaction
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