[unit test] Complete all providers unit tests #12
All checks were successful
Blockstorage/repertory/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-09-16 18:27:52 -05:00
parent af929064a9
commit 891070146e
2 changed files with 15 additions and 16 deletions

View File

@@ -542,18 +542,11 @@ auto s3_provider::get_file(const std::string &api_path, api_file &file) const
file.accessed_date = file.changed_date = file.creation_date =
file.modified_date = result.last_modified;
file.key = is_encrypted ? utils::path::create_api_path(object_name) : "";
std::string size_str;
if (get_item_meta(file.api_path, META_SIZE, size_str) ==
api_error::success) {
file.file_size = utils::string::to_uint64(size_str);
} else {
file.file_size =
is_encrypted
? utils::encryption::encrypting_reader::calculate_decrypted_size(
result.content_length, not legacy_bucket_)
: result.content_length;
}
return add_if_not_found(file, object_name);
} catch (const std::exception &e) {

View File

@@ -753,6 +753,7 @@ static void get_file_size(i_provider &provider) {
auto &file = test::create_random_file(128U);
auto api_path =
fmt::format("/{}", utils::path::strip_to_file_name(file.get_path()));
create_file(provider, api_path);
stop_type stop_requested{false};
auto res = provider.upload_file(api_path, file.get_path(), stop_requested);
@@ -808,20 +809,24 @@ static void get_filesystem_item(i_provider &provider) {
return;
}
auto &src = test::create_random_file(128U);
auto &file = test::create_random_file(128U);
auto api_path =
fmt::format("/{}", utils::path::strip_to_file_name(src.get_path()));
fmt::format("/{}", utils::path::strip_to_file_name(file.get_path()));
create_file(provider, api_path);
stop_type stop_requested{false};
auto res = provider.upload_file(api_path, src.get_path(), stop_requested);
auto res = provider.upload_file(api_path, file.get_path(), stop_requested);
ASSERT_EQ(api_error::success, res);
EXPECT_EQ(api_error::success,
provider.set_item_meta(api_path, META_SIZE,
std::to_string(*file.size())));
filesystem_item fsi{};
res = provider.get_filesystem_item(api_path, false, fsi);
EXPECT_EQ(api_error::success, res);
EXPECT_EQ(api_path, fsi.api_path);
EXPECT_FALSE(fsi.directory);
EXPECT_EQ(*src.size(), fsi.size);
EXPECT_EQ(*file.size(), fsi.size);
res = provider.remove_file(api_path);
EXPECT_EQ(api_error::success, res);
@@ -882,6 +887,7 @@ static void get_filesystem_item_from_source_path(const app_config &cfg,
api_path =
fmt::format("/{}", utils::path::strip_to_file_name(file.get_path()));
source_path = file.get_path();
create_file(provider, api_path);
EXPECT_EQ(
api_error::success,