Skip to content
Snippets Groups Projects
Commit 7529a36a authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

TST: check empty file"

parent 6b87d2fa
Branches f-empty
No related tags found
No related merge requests found
Pipeline #53279 failed
......@@ -94,6 +94,7 @@ public:
protected:
fs::path test_upload_file_1;
fs::path test_empty_file_1;
fs::path test_download_file_1;
// Fixture methods //////////////////////////////////////////////////////////
......@@ -102,6 +103,7 @@ protected:
DeleteEntities();
test_upload_file_1 = fs::path("test_upload_file_1_delete_me.dat");
test_empty_file_1 = fs::path("test_empty_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
......@@ -115,6 +117,7 @@ protected:
void TearDown() override {
// delete files
fs::remove(test_upload_file_1);
//fs::remove(test_empty_file_1);
fs::remove(test_download_file_1);
DeleteEntities();
}
......@@ -955,13 +958,54 @@ TEST_F(test_transaction, test_file_up_n_download) {
FileReader reader_remote(test_upload_file_1);
std::string buffer_local(1024, 'c');
std::string buffer_remote(1024, 'c');
std::string buffer_remote(1024, '0');
for (int i = 0; i < 8; i++) {
reader_remote.read(buffer_remote);
EXPECT_EQ(buffer_remote, buffer_local);
}
}
/*
* create a file object, upload and then download it
*/
TEST_F(test_transaction, test_empyt_file) {
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
Entity file;
file.SetRole(Role::FILE);
file.SetFilePath("test.txt");
file.SetLocalPath(test_empty_file_1);
auto insert_transaction(connection->CreateTransaction());
insert_transaction->InsertEntity(&file);
insert_transaction->Execute();
const auto &insert_results = insert_transaction->GetResultSet();
const auto &inserted_file = insert_results.at(0);
ASSERT_FALSE(inserted_file.GetId().empty());
ASSERT_FALSE(inserted_file.HasErrors());
auto download_transaction(connection->CreateTransaction());
download_transaction->RetrieveAndDownloadFileById(
inserted_file.GetId(), test_download_file_1.string());
download_transaction->ExecuteAsynchronously();
ASSERT_EQ(download_transaction->WaitForIt().GetCode(), StatusCode::SUCCESS);
const auto &download_results = download_transaction->GetResultSet();
ASSERT_EQ(download_results.size(), 1);
const auto &downloaded_file = download_results.at(0);
ASSERT_FALSE(downloaded_file.GetId().empty());
ASSERT_FALSE(downloaded_file.HasErrors());
EXPECT_EQ(downloaded_file.GetLocalPath().string(),
test_download_file_1.string());
//checkfile size??/
}
/*
* Test a small worklfow
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment