Skip to content
Snippets Groups Projects
Commit a5d1a6e8 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

fix tests

parent 31270ca3
Branches
Tags
No related merge requests found
......@@ -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;
}
......
......@@ -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()) {
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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")
......@@ -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")
......@@ -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")
......@@ -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")
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment