[unit test] Complete all providers unit tests #12
This commit is contained in:
@@ -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.accessed_date = file.changed_date = file.creation_date =
|
||||||
file.modified_date = result.last_modified;
|
file.modified_date = result.last_modified;
|
||||||
file.key = is_encrypted ? utils::path::create_api_path(object_name) : "";
|
file.key = is_encrypted ? utils::path::create_api_path(object_name) : "";
|
||||||
|
file.file_size =
|
||||||
std::string size_str;
|
is_encrypted
|
||||||
if (get_item_meta(file.api_path, META_SIZE, size_str) ==
|
? utils::encryption::encrypting_reader::calculate_decrypted_size(
|
||||||
api_error::success) {
|
result.content_length, not legacy_bucket_)
|
||||||
file.file_size = utils::string::to_uint64(size_str);
|
: result.content_length;
|
||||||
} 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);
|
return add_if_not_found(file, object_name);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
@@ -753,6 +753,7 @@ static void get_file_size(i_provider &provider) {
|
|||||||
auto &file = test::create_random_file(128U);
|
auto &file = test::create_random_file(128U);
|
||||||
auto api_path =
|
auto api_path =
|
||||||
fmt::format("/{}", utils::path::strip_to_file_name(file.get_path()));
|
fmt::format("/{}", utils::path::strip_to_file_name(file.get_path()));
|
||||||
|
create_file(provider, api_path);
|
||||||
|
|
||||||
stop_type stop_requested{false};
|
stop_type stop_requested{false};
|
||||||
auto res = provider.upload_file(api_path, file.get_path(), stop_requested);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &src = test::create_random_file(128U);
|
auto &file = test::create_random_file(128U);
|
||||||
auto api_path =
|
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};
|
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);
|
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{};
|
filesystem_item fsi{};
|
||||||
res = provider.get_filesystem_item(api_path, false, fsi);
|
res = provider.get_filesystem_item(api_path, false, fsi);
|
||||||
EXPECT_EQ(api_error::success, res);
|
EXPECT_EQ(api_error::success, res);
|
||||||
EXPECT_EQ(api_path, fsi.api_path);
|
EXPECT_EQ(api_path, fsi.api_path);
|
||||||
EXPECT_FALSE(fsi.directory);
|
EXPECT_FALSE(fsi.directory);
|
||||||
EXPECT_EQ(*src.size(), fsi.size);
|
EXPECT_EQ(*file.size(), fsi.size);
|
||||||
|
|
||||||
res = provider.remove_file(api_path);
|
res = provider.remove_file(api_path);
|
||||||
EXPECT_EQ(api_error::success, res);
|
EXPECT_EQ(api_error::success, res);
|
||||||
@@ -882,6 +887,7 @@ static void get_filesystem_item_from_source_path(const app_config &cfg,
|
|||||||
api_path =
|
api_path =
|
||||||
fmt::format("/{}", utils::path::strip_to_file_name(file.get_path()));
|
fmt::format("/{}", utils::path::strip_to_file_name(file.get_path()));
|
||||||
source_path = file.get_path();
|
source_path = file.get_path();
|
||||||
|
create_file(provider, api_path);
|
||||||
|
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
api_error::success,
|
api_error::success,
|
||||||
|
Reference in New Issue
Block a user