Compare commits
2 Commits
e013cbbdbb
...
26358b1e67
Author | SHA1 | Date | |
---|---|---|---|
26358b1e67 | |||
feeef3a044 |
@ -171,10 +171,6 @@ void rdb_file_db::enumerate_item_list(
|
||||
callback(list);
|
||||
list.clear();
|
||||
}
|
||||
|
||||
if (not list.empty()) {
|
||||
callback(list);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@ -194,12 +190,12 @@ void rdb_file_db::enumerate_item_list(
|
||||
callback(list);
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (not list.empty()) {
|
||||
callback(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto rdb_file_db::get_api_path(const std::string &source_path,
|
||||
std::string &api_path) const -> api_error {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user