[unit test] Complete all providers unit tests #12

This commit is contained in:
2025-09-17 12:05:20 -05:00
parent 3a83a5fd5e
commit 52e84f95fb

View File

@@ -173,7 +173,7 @@ const auto decrypt_parts = [](const repertory::app_config &cfg,
path = repertory::utils::string::join(parts, '/');
}
};
/*
[[nodiscard]] auto read_all_plain(const std::string &path) -> std::string {
repertory::utils::file::file file{path};
auto data = file.read_all();
@@ -185,13 +185,15 @@ const auto decrypt_parts = [](const repertory::app_config &cfg,
const std::string &api_path,
std::uint64_t total) -> std::string {
std::string out{};
std::uint64_t off = 0U;
static constexpr std::uint64_t chunks[] = {1U, 7U, 64U, 3U, 1024U, 5U};
std::size_t idx = 0U;
std::uint64_t off{0U};
constexpr const std::array<std::uint64_t, 6U> chunks{
1U, 7U, 64U, 3U, 1024U, 5U,
};
std::size_t idx{0U};
while (off < total) {
const auto want =
std::min<std::uint64_t>(chunks[idx % std::size(chunks)], total - off);
auto want = std::min<std::uint64_t>(chunks.at(idx % std::size(chunks)),
total - off);
std::string part{};
EXPECT_EQ(api_error::success,
provider.read_file_bytes(api_path, off, want, part));
@@ -201,7 +203,7 @@ const auto decrypt_parts = [](const repertory::app_config &cfg,
++idx;
}
return out;
}
} */
} // namespace
namespace repertory {
@@ -1294,27 +1296,23 @@ static void get_total_item_count(i_provider &provider) {
__FUNCTION__);
if (provider.is_read_only()) {
std::uint64_t count{};
EXPECT_EQ(api_error::success, provider.get_total_item_count(count));
std::uint64_t count{provider.get_total_item_count()};
EXPECT_EQ(3U, count);
return;
}
std::uint64_t before{};
EXPECT_EQ(api_error::success, provider.get_total_item_count(before));
std::uint64_t before{provider.get_total_item_count()};
create_file(provider, "/count01.txt");
create_file(provider, "/count02.txt");
std::uint64_t mid{};
EXPECT_EQ(api_error::success, provider.get_total_item_count(mid));
std::uint64_t mid{provider.get_total_item_count()};
EXPECT_EQ(before + 2U, mid);
EXPECT_EQ(api_error::success, provider.remove_file("/count01.txt"));
EXPECT_EQ(api_error::success, provider.remove_file("/count02.txt"));
std::uint64_t after{};
EXPECT_EQ(api_error::success, provider.get_total_item_count(after));
std::uint64_t after{provider.get_total_item_count()};
EXPECT_EQ(before, after);
}
@@ -1381,11 +1379,10 @@ static void get_total_drive_space(i_provider &provider) {
app_config::get_provider_name(provider.get_provider_type()),
__FUNCTION__);
std::uint64_t total{};
auto res_total = provider.get_total_drive_space(total);
EXPECT_EQ(api_error::success, res_total);
std::uint64_t total{provider.get_total_drive_space()};
std::uint64_t used{provider.get_used_drive_space(used)};
std::uint64_t used{provider.get_used_drive_space()};
EXPECT_EQ(api_error::success, );
if (total != 0U) {
EXPECT_GE(total, used);