From a5d1a6e81963d6a3062c0f8d4f7c5300592316b0 Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Tue, 2 Nov 2021 20:03:06 +0100
Subject: [PATCH] fix tests

---
 common/cpp/include/asapo/common/error.tpp                 | 6 +++---
 common/cpp/src/system_io/system_io.cpp                    | 8 ++++----
 common/cpp/src/system_io/system_io_linux_mac.cpp          | 6 +++---
 common/cpp/src/system_io/system_io_windows.cpp            | 6 +++---
 .../automatic/system_io/read_file_content/CMakeLists.txt  | 4 ++--
 .../system_io/read_folder_content/CMakeLists.txt          | 4 ++--
 .../system_io/read_string_from_file/CMakeLists.txt        | 4 ++--
 .../system_io/read_subdirectories/CMakeLists.txt          | 4 ++--
 .../automatic/system_io/write_data_to_file/CMakeLists.txt | 2 +-
 9 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/common/cpp/include/asapo/common/error.tpp b/common/cpp/include/asapo/common/error.tpp
index d0a2807d0..35b6f8da4 100644
--- a/common/cpp/include/asapo/common/error.tpp
+++ b/common/cpp/include/asapo/common/error.tpp
@@ -56,10 +56,10 @@ template<typename ServiceErrorType>
 std::string ServiceError<ServiceErrorType>::Explain() const noexcept {
     std::string err = "error: " + error_name_;
     if (!error_message_.empty()) {
-        err += "; message: " + error_message_;
+        err += ", message: " + error_message_;
     }
     if (!context_.empty()) {
-        err += "; context: ";
+        err += ", context: ";
         auto i = 0;
         for (const auto &kv : context_) {
             err += (i > 0 ? ", " : "") + kv.first + ":" + kv.second;
@@ -67,7 +67,7 @@ std::string ServiceError<ServiceErrorType>::Explain() const noexcept {
         }
     }
     if (cause_err_ != nullptr) {
-        err +=  "; caused by: " + cause_err_->Explain() ;
+        err +=  ", caused by: " + cause_err_->Explain() ;
     }
     return err;
 }
diff --git a/common/cpp/src/system_io/system_io.cpp b/common/cpp/src/system_io/system_io.cpp
index 096315a6d..3165a6a3d 100644
--- a/common/cpp/src/system_io/system_io.cpp
+++ b/common/cpp/src/system_io/system_io.cpp
@@ -116,7 +116,7 @@ MessageData SystemIO::GetDataFromFile(const std::string& fname, uint64_t* fsize,
 
     Read(fd, data_array, (size_t)*fsize, err);
     if (*err != nullptr) {
-        (*err)->AddContext("filename", fname)->AddContext("expected size", std::to_string(*fsize));
+        (*err)->AddContext("name", fname)->AddContext("expected size", std::to_string(*fsize));
         Close(fd, nullptr);
         return nullptr;
     }
@@ -191,7 +191,7 @@ Error SystemIO::WriteDataToFile(const std::string& root_folder, const std::strin
 
     Write(fd, data, length, &err);
     if (err) {
-        err->AddContext("filename", fname);
+        err->AddContext("name", fname);
         return err;
     }
 
@@ -402,7 +402,7 @@ asapo::FileDescriptor asapo::SystemIO::Open(const std::string& filename,
     FileDescriptor fd = _open(filename.c_str(), flags);
     if (fd == -1) {
         *err = GetLastError();
-        (*err)->AddContext("filename", filename);
+        (*err)->AddContext("name", filename);
     } else {
         *err = nullptr;
     }
@@ -616,7 +616,7 @@ Error SystemIO::CreateDirectoryWithParents(const std::string& root_path, const s
         Error err;
         CreateNewDirectory(new_path, &err);
         if (err && err != IOErrorTemplates::kFileAlreadyExists) {
-            err->AddContext("path", new_path);
+            err->AddContext("name", new_path);
             return err;
         }
         if (iter != path.end()) {
diff --git a/common/cpp/src/system_io/system_io_linux_mac.cpp b/common/cpp/src/system_io/system_io_linux_mac.cpp
index bf913db61..371c12e4d 100644
--- a/common/cpp/src/system_io/system_io_linux_mac.cpp
+++ b/common/cpp/src/system_io/system_io_linux_mac.cpp
@@ -122,7 +122,7 @@ MessageMeta GetMessageMeta(const string& name, Error* err) {
 
     auto t_stat = FileStat(name, err);
     if (*err != nullptr) {
-        (*err)->AddContext("filename", name);
+        (*err)->AddContext("name", name);
         return MessageMeta{};
     }
 
@@ -157,7 +157,7 @@ void SystemIO::GetSubDirectoriesRecursively(const std::string& path, SubDirList*
     auto dir = opendir((path).c_str());
     if (dir == nullptr) {
         *err = GetLastError();
-        (*err)->AddContext("path", path);
+        (*err)->AddContext("name", path);
         return;
     }
 
@@ -183,7 +183,7 @@ void SystemIO::CollectMessageMetarmationRecursively(const std::string& path,
     auto dir = opendir((path).c_str());
     if (dir == nullptr) {
         *err = GetLastError();
-        (*err)->AddContext("path", path);
+        (*err)->AddContext("name", path);
         return;
     }
 
diff --git a/common/cpp/src/system_io/system_io_windows.cpp b/common/cpp/src/system_io/system_io_windows.cpp
index 282cf5523..b847d747b 100644
--- a/common/cpp/src/system_io/system_io_windows.cpp
+++ b/common/cpp/src/system_io/system_io_windows.cpp
@@ -151,7 +151,7 @@ MessageMeta SystemIO::GetMessageMeta(const std::string& name, Error* err) const
     auto hFind = FindFirstFile(name.c_str(), &f);
     if (hFind == INVALID_HANDLE_VALUE) {
         *err = IOErrorFromGetLastError();
-        (*err)->AddContext("filename", name);
+        (*err)->AddContext("name", name);
         return {};
     }
     FindClose(hFind);
@@ -179,7 +179,7 @@ void SystemIO::GetSubDirectoriesRecursively(const std::string& path, SubDirList*
     HANDLE handle = FindFirstFile((path + "\\*.*").c_str(), &find_data);
     if (handle == INVALID_HANDLE_VALUE) {
         *err = IOErrorFromGetLastError();
-        (*err)->AddContext("path", path);
+        (*err)->AddContext("name", path);
         return;
     }
 
@@ -208,7 +208,7 @@ void SystemIO::CollectMessageMetarmationRecursively(const std::string& path,
     HANDLE handle = FindFirstFile((path + "\\*.*").c_str(), &find_data);
     if (handle == INVALID_HANDLE_VALUE) {
         *err = IOErrorFromGetLastError();
-        (*err)->AddContext("path", path);
+        (*err)->AddContext("name", path);
         return;
     }
 
diff --git a/tests/automatic/system_io/read_file_content/CMakeLists.txt b/tests/automatic/system_io/read_file_content/CMakeLists.txt
index ca5a9e0de..5f302cdb1 100644
--- a/tests/automatic/system_io/read_file_content/CMakeLists.txt
+++ b/tests/automatic/system_io/read_file_content/CMakeLists.txt
@@ -17,6 +17,6 @@ set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
 add_test_setup_cleanup(${TARGET_NAME})
 add_integration_test(${TARGET_NAME} readfile "test/1 123")
 add_integration_test(${TARGET_NAME} readfile_unkown_size "test/2 unknown_size")
-add_integration_test(${TARGET_NAME} filenotfound "test_notexist Nosuchfileordirectory:test_notexist")
-add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess Permissiondenied:file_noaccess")
+add_integration_test(${TARGET_NAME} filenotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist")
+add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess error:Permissiondenied,context:name:file_noaccess")
 
diff --git a/tests/automatic/system_io/read_folder_content/CMakeLists.txt b/tests/automatic/system_io/read_folder_content/CMakeLists.txt
index eb323e8c3..42bc1ec48 100644
--- a/tests/automatic/system_io/read_folder_content/CMakeLists.txt
+++ b/tests/automatic/system_io/read_folder_content/CMakeLists.txt
@@ -27,6 +27,6 @@ ELSE()
 ENDIF(WIN32)
 
 
-add_integration_test(${TARGET_NAME} foldernotfound "test_notexist Nosuchfileordirectory:test_notexist")
-add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 Permissiondenied:test_noaccess1")
+add_integration_test(${TARGET_NAME} foldernotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist")
+add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 error:Permissiondenied,context:name:test_noaccess1")
 
diff --git a/tests/automatic/system_io/read_string_from_file/CMakeLists.txt b/tests/automatic/system_io/read_string_from_file/CMakeLists.txt
index 6e133cc60..8cfa3aed8 100644
--- a/tests/automatic/system_io/read_string_from_file/CMakeLists.txt
+++ b/tests/automatic/system_io/read_string_from_file/CMakeLists.txt
@@ -16,6 +16,6 @@ set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
 
 add_test_setup_cleanup(${TARGET_NAME})
 add_integration_test(${TARGET_NAME} readfile "test/1 123")
-add_integration_test(${TARGET_NAME} filenotfound "test_notexist Nosuchfileordirectory:test_notexist")
-add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess Permissiondenied:file_noaccess")
+add_integration_test(${TARGET_NAME} filenotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist")
+add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess error:Permissiondenied,context:name:file_noaccess")
 
diff --git a/tests/automatic/system_io/read_subdirectories/CMakeLists.txt b/tests/automatic/system_io/read_subdirectories/CMakeLists.txt
index 6b24dd256..ab9b1908f 100644
--- a/tests/automatic/system_io/read_subdirectories/CMakeLists.txt
+++ b/tests/automatic/system_io/read_subdirectories/CMakeLists.txt
@@ -27,6 +27,6 @@ ELSE()
 ENDIF(WIN32)
 
 
-add_integration_test(${TARGET_NAME} foldernotfound "test_notexist Nosuchfileordirectory:test_notexist")
-add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 Permissiondenied:test_noaccess1")
+add_integration_test(${TARGET_NAME} foldernotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist")
+add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 error:Permissiondenied,context:name:test_noaccess1")
 
diff --git a/tests/automatic/system_io/write_data_to_file/CMakeLists.txt b/tests/automatic/system_io/write_data_to_file/CMakeLists.txt
index d10f4fcee..3e7a13c46 100644
--- a/tests/automatic/system_io/write_data_to_file/CMakeLists.txt
+++ b/tests/automatic/system_io/write_data_to_file/CMakeLists.txt
@@ -22,5 +22,5 @@ else ()
 endif()
 
 add_integration_test(${TARGET_NAME} writetwice "test_file ok dummy" nomem)
-add_integration_test(${TARGET_NAME} dirnoaccess "test_noaccess/test_file error Permissiondenied:test_noaccess/test_file" nomem)
+add_integration_test(${TARGET_NAME} dirnoaccess "test_noaccess/test_file error error:Permissiondenied,context:name:test_noaccess/test_file" nomem)
 
-- 
GitLab