2 Commits

Author SHA1 Message Date
26358b1e67 unit tests and fixes
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
2025-01-25 06:20:50 -06:00
feeef3a044 added unit tests 2025-01-25 06:13:07 -06:00
3 changed files with 61 additions and 7 deletions

View File

@ -171,10 +171,6 @@ void rdb_file_db::enumerate_item_list(
callback(list);
list.clear();
}
if (not list.empty()) {
callback(list);
}
}
{
@ -194,10 +190,10 @@ void rdb_file_db::enumerate_item_list(
callback(list);
list.clear();
}
}
if (not list.empty()) {
callback(list);
}
if (not list.empty()) {
callback(list);
}
}

View File

@ -21,6 +21,7 @@
*/
#include "fixtures/file_db_fixture.hpp"
#include <filesystem>
namespace {
const auto get_stop_requested = []() -> bool { return false; };
@ -339,4 +340,30 @@ TYPED_TEST(file_db_test, item_not_found_is_returned_for_non_existing_api_path) {
this->file_db->get_source_path("/file", source_path));
EXPECT_TRUE(source_path.empty());
}
TYPED_TEST(file_db_test, can_enumerate_item_list) {
this->file_db->clear();
EXPECT_EQ(api_error::success,
this->file_db->add_directory("/", std::filesystem::current_path()));
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
"/file",
0U,
{},
"c:\\test\\file.txt",
}));
auto call_count{0U};
const auto get_stop_requested = []() -> bool { return false; };
this->file_db->enumerate_item_list(
[&call_count](auto &&list) {
EXPECT_EQ(std::size_t(2U), list.size());
++call_count;
},
get_stop_requested);
EXPECT_EQ(std::size_t(1U), call_count);
}
} // namespace repertory

View File

@ -615,4 +615,35 @@ TYPED_TEST(meta_db_test, check_set_item_meta_file_defaults) {
EXPECT_EQ(0U, utils::string::to_uint64(meta[META_SIZE]));
EXPECT_TRUE(meta[META_SOURCE].empty());
}
TYPED_TEST(meta_db_test, can_enumerate_api_path_list) {
this->meta_db->clear();
auto test_dir = create_test_file();
EXPECT_EQ(api_error::success,
this->meta_db->set_item_meta(
test_dir, {
{META_DIRECTORY, utils::string::from_bool(true)},
}));
auto test_file = create_test_file();
EXPECT_EQ(
api_error::success,
this->meta_db->set_item_meta(
test_file, {
{META_DIRECTORY, utils::string::from_bool(false)},
}));
auto call_count{0U};
const auto get_stop_requested = []() -> bool { return false; };
this->meta_db->enumerate_api_path_list(
[&call_count](auto &&list) {
EXPECT_EQ(std::size_t(2U), list.size());
++call_count;
},
get_stop_requested);
EXPECT_EQ(std::size_t(1U), call_count);
}
} // namespace repertory