[unit test] Complete all providers unit tests #12
Some checks are pending
Blockstorage/repertory/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head Build started...

This commit is contained in:
2025-09-17 19:06:30 -05:00
parent 17bc1b41c6
commit 3d798ca17e

View File

@@ -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
/*