From feeef3a044c7acb7017d02b79d561e8c40307a0f Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sat, 25 Jan 2025 06:13:07 -0600 Subject: [PATCH] added unit tests --- repertory/repertory_test/src/file_db_test.cpp | 25 +++++++++++++++ repertory/repertory_test/src/meta_db_test.cpp | 31 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/repertory/repertory_test/src/file_db_test.cpp b/repertory/repertory_test/src/file_db_test.cpp index dc941626..397a6b52 100644 --- a/repertory/repertory_test/src/file_db_test.cpp +++ b/repertory/repertory_test/src/file_db_test.cpp @@ -339,4 +339,29 @@ 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("/", "c:\\test")); + 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 diff --git a/repertory/repertory_test/src/meta_db_test.cpp b/repertory/repertory_test/src/meta_db_test.cpp index 3da58d6a..8e79fee2 100644 --- a/repertory/repertory_test/src/meta_db_test.cpp +++ b/repertory/repertory_test/src/meta_db_test.cpp @@ -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