diff --git a/repertory/repertory_test/src/meta_db_test.cpp b/repertory/repertory_test/src/meta_db_test.cpp index bf779075..ef623093 100644 --- a/repertory/repertory_test/src/meta_db_test.cpp +++ b/repertory/repertory_test/src/meta_db_test.cpp @@ -249,4 +249,35 @@ TYPED_TEST(meta_db_test, can_get_individual_item_meta_for_file) { EXPECT_STREQ(source_path.c_str(), value.c_str()); } } + +TYPED_TEST(meta_db_test, can_get_pinned_files) { + std::vector pinned_files{}; + std::vector unpinned_files{}; + for (auto idx = 0U; idx < 20U; ++idx) { + auto test_file = create_test_file(); + auto pinned = idx % 2U == 0U; + EXPECT_EQ( + api_error::success, + this->meta_db->set_item_meta( + test_file, { + {META_DIRECTORY, utils::string::from_bool(false)}, + {META_PINNED, utils::string::from_bool(pinned)}, + })); + if (pinned) { + pinned_files.push_back(test_file); + continue; + } + unpinned_files.push_back(test_file); + } + + auto pinned = this->meta_db->get_pinned_files(); + EXPECT_GE(pinned.size(), pinned_files.size()); + for (const auto &api_path : pinned_files) { + EXPECT_TRUE(utils::collection::includes(pinned, api_path)); + } + + for (const auto &api_path : unpinned_files) { + EXPECT_TRUE(utils::collection::excludes(pinned, api_path)); + } +} } // namespace repertory