diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 62c9504c5dbf750ad5f7165d6261e3e7c6fed3d2..ecb011e99179399e62f646f3027951aff0163466 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,6 +24,7 @@ set(test_cases test_connection test_transaction + #test_file_transmission TODO add once fixed test_ccaosdb ) diff --git a/test/test_file_transmission.cpp b/test/test_file_transmission.cpp index 7c6a72d0b4d52ecd76d01d253e377473ce7954cf..fb42d893783534097f834235d4cfaba789f37c8d 100644 --- a/test/test_file_transmission.cpp +++ b/test/test_file_transmission.cpp @@ -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 {} diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp index e51ccd6d0c03691b3067f3f4e522dc29a1419356..a3182843d81520a91e8f4932bb1f023172a98d4a 100644 --- a/test/test_transaction.cpp +++ b/test/test_transaction.cpp @@ -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