From 981ba360ff7e00a5630c445fef178a423e383e5b Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Wed, 1 Sep 2021 17:48:52 +0200
Subject: [PATCH] TEST: Downloading files > 16kiB

---
 test/test_ccaosdb.cpp     |  2 +-
 test/test_transaction.cpp | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/test/test_ccaosdb.cpp b/test/test_ccaosdb.cpp
index ecc3eb5..c588d10 100644
--- a/test/test_ccaosdb.cpp
+++ b/test/test_ccaosdb.cpp
@@ -46,7 +46,7 @@ protected:
     // fill the file that shall be uploaded
     caosdb::transaction::FileWriter writer(test_upload_file_1);
     std::string buffer(1024, 'c');
-    for (int i = 0; i < 8; i++) {
+    for (int i = 0; i < 20; i++) {
       writer.write(buffer);
     }
   }
diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp
index d98c68f..683f85f 100644
--- a/test/test_transaction.cpp
+++ b/test/test_transaction.cpp
@@ -96,6 +96,7 @@ public:
 protected:
   fs::path test_upload_file_1;
   fs::path test_download_file_1;
+  size_t test_file_size_kib = 20;  // We should test at least something over 16kiB
 
   // Fixture methods //////////////////////////////////////////////////////////
 
@@ -108,7 +109,7 @@ protected:
     // 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++) {
+    for (int i = 0; i < test_file_size_kib; i++) {
       writer.write(buffer);
     }
   }
@@ -951,14 +952,20 @@ TEST_F(test_transaction, test_file_up_n_download) {
   ASSERT_FALSE(downloaded_file.HasErrors());
   EXPECT_EQ(downloaded_file.GetLocalPath().string(),
             test_download_file_1.string());
+  EXPECT_EQ(fs::file_size(test_upload_file_1),
+            fs::file_size(test_download_file_1));
+  // test_download_file_1
 
-  FileReader reader_remote(test_upload_file_1);
+  FileReader reader_remote(test_download_file_1);
   std::string buffer_local(1024, 'c');
   std::string buffer_remote(1024, 'c');
-  for (int i = 0; i < 8; i++) {
+  std::cout << "Reading kiB chunk";
+  for (size_t i = 0; i < test_file_size_kib; i++) {
+    std::cout << " #" << i+1 << "/" << test_file_size_kib;
     reader_remote.read(buffer_remote);
     EXPECT_EQ(buffer_remote, buffer_local);
   }
+  std::cout << std::endl;
 }
 
 /*
-- 
GitLab