updated build system
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
@ -53,6 +53,8 @@ static void decrypt_and_verify(const buffer_t &buffer, std::string_view token,
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||
|
||||
auto generate_test_directory() -> utils::file::i_directory &;
|
||||
|
||||
[[nodiscard]] auto get_test_input_dir() -> std::string;
|
||||
|
||||
[[nodiscard]] auto get_test_output_dir() -> std::string;
|
||||
|
@ -24,7 +24,7 @@
|
||||
namespace {
|
||||
static std::recursive_mutex file_mtx{};
|
||||
|
||||
static std::vector<std::unique_ptr<repertory::utils::file::i_file>>
|
||||
static std::vector<std::unique_ptr<repertory::utils::file::i_fs_item>>
|
||||
generated_files{};
|
||||
|
||||
static void delete_generated_files() {
|
||||
@ -32,8 +32,7 @@ static void delete_generated_files() {
|
||||
std::optional<std::string> parent_path;
|
||||
for (auto &&path : generated_files) {
|
||||
if (parent_path->empty()) {
|
||||
parent_path =
|
||||
repertory::utils::path::get_parent_path(path->get_path());
|
||||
parent_path = repertory::utils::path::get_parent_path(path->get_path());
|
||||
}
|
||||
|
||||
[[maybe_unused]] auto removed = path->remove();
|
||||
@ -73,10 +72,25 @@ auto create_random_file(std::size_t size) -> utils::file::i_file & {
|
||||
}
|
||||
|
||||
generated_files.emplace_back(std::move(file));
|
||||
return *generated_files.back();
|
||||
return *dynamic_cast<utils::file::i_file *>(generated_files.back().get());
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
auto generate_test_directory() -> utils::file::i_directory & {
|
||||
recur_mutex_lock lock{file_mtx};
|
||||
|
||||
auto path = utils::path::combine(
|
||||
get_test_output_dir(),
|
||||
{
|
||||
std::string{"test_dir"} + std::to_string(generated_files.size()),
|
||||
});
|
||||
generated_files.emplace_back(std::unique_ptr<utils::file::i_fs_item>(
|
||||
new utils::file::directory{path}));
|
||||
|
||||
return *dynamic_cast<utils::file::i_directory *>(
|
||||
generated_files.back().get());
|
||||
}
|
||||
|
||||
auto generate_test_file_name(std::string_view file_name_no_extension)
|
||||
-> std::string {
|
||||
recur_mutex_lock lock{file_mtx};
|
||||
|
@ -262,4 +262,42 @@ TEST(utils_file, smb_parent_is_not_same) {
|
||||
EXPECT_FALSE(utils::file::smb_parent_is_same(path1, path2));
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBDSM)
|
||||
|
||||
TEST(util_file, directory_exists_in_path) {
|
||||
auto &test_dir = test::generate_test_directory();
|
||||
auto sub_dir = test_dir.create_directory("moose");
|
||||
EXPECT_TRUE(sub_dir != nullptr);
|
||||
if (sub_dir) {
|
||||
EXPECT_TRUE(
|
||||
utils::file::directory_exists_in_path(test_dir.get_path(), "moose"));
|
||||
|
||||
EXPECT_FALSE(
|
||||
utils::file::file_exists_in_path(test_dir.get_path(), "moose"));
|
||||
|
||||
EXPECT_TRUE(utils::file::directory_exists_in_path(
|
||||
utils::string::from_utf8(test_dir.get_path()), L"moose"));
|
||||
|
||||
EXPECT_FALSE(utils::file::file_exists_in_path(
|
||||
utils::string::from_utf8(test_dir.get_path()), L"moose"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(util_file, file_exists_in_path) {
|
||||
auto &test_dir = test::generate_test_directory();
|
||||
auto sub_file = test_dir.create_file("moose.txt", false);
|
||||
EXPECT_TRUE(sub_file != nullptr);
|
||||
if (sub_file) {
|
||||
EXPECT_TRUE(
|
||||
utils::file::file_exists_in_path(test_dir.get_path(), "moose.txt"));
|
||||
|
||||
EXPECT_FALSE(utils::file::directory_exists_in_path(test_dir.get_path(),
|
||||
"moose.txt"));
|
||||
|
||||
EXPECT_TRUE(utils::file::file_exists_in_path(
|
||||
utils::string::from_utf8(test_dir.get_path()), L"moose.txt"));
|
||||
|
||||
EXPECT_FALSE(utils::file::directory_exists_in_path(
|
||||
utils::string::from_utf8(test_dir.get_path()), L"moose.txt"));
|
||||
}
|
||||
}
|
||||
} // namespace repertory
|
||||
|
Reference in New Issue
Block a user