From 3d798ca17e3fe1f2f760ac1094625b23cf524b6d Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 17 Sep 2025 19:06:30 -0500 Subject: [PATCH] [unit test] Complete all providers unit tests #12 --- .../repertory_test/src/providers_test.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/repertory/repertory_test/src/providers_test.cpp b/repertory/repertory_test/src/providers_test.cpp index 1cede56b..bcd6afb6 100644 --- a/repertory/repertory_test/src/providers_test.cpp +++ b/repertory/repertory_test/src/providers_test.cpp @@ -1558,6 +1558,47 @@ static void rename_file_fails_if_destination_exists(i_provider &provider) { EXPECT_EQ(api_error::success, provider.remove_file(dst)); } +static void +rename_file_fails_if_destination_is_directory(i_provider &provider) { + fmt::println("testing|{}|{}", + app_config::get_provider_name(provider.get_provider_type()), + __FUNCTION__); + + if (not provider.is_rename_supported()) { + if (provider.get_provider_type() != provider_type::encrypt) { + create_file(provider, "/rn_src_conflict.txt"); + create_directory(provider, "/rn_dst_conflict"); + } + auto res = provider.rename_file("/rn_src_conflict.txt", "/rn_dst_conflict"); + EXPECT_EQ(api_error::not_implemented, res); + + if (provider.get_provider_type() != provider_type::encrypt) { + EXPECT_EQ(api_error::success, + provider.remove_file("/rn_src_conflict.txt")); + EXPECT_EQ(api_error::success, + provider.remove_directory("/rn_dst_conflict")); + } + return; + } + + std::string src{"/rn_src_conflict.txt"}; + std::string dst{"/rn_dst_conflict"}; + create_file(provider, src); + create_directory(provider, dst); + + auto res = provider.rename_file(src, dst); + EXPECT_EQ(api_error::directory_exists, res); + + bool exists{}; + EXPECT_EQ(api_error::success, provider.is_file(src, exists)); + EXPECT_TRUE(exists); + EXPECT_EQ(api_error::success, provider.is_directory(dst, exists)); + EXPECT_TRUE(exists); + + EXPECT_EQ(api_error::success, provider.remove_file(src)); + EXPECT_EQ(api_error::success, provider.remove_directory(dst)); +} + static void run_tests(const app_config &cfg, i_provider &provider) { // MOVED get_file_list(cfg, provider); @@ -1631,6 +1672,7 @@ static void run_tests(const app_config &cfg, i_provider &provider) { rename_file(provider); rename_file_fails_if_source_not_found(provider); rename_file_fails_if_destination_exists(provider); + rename_file_fails_if_destination_is_directory(provider); // TODO need to test read when file size changes for encrypt provider /*