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