added unit tests
This commit is contained in:
@ -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));
|
this->file_db->get_source_path("/file", source_path));
|
||||||
EXPECT_TRUE(source_path.empty());
|
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
|
} // 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_EQ(0U, utils::string::to_uint64(meta[META_SIZE]));
|
||||||
EXPECT_TRUE(meta[META_SOURCE].empty());
|
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
|
} // namespace repertory
|
||||||
|
Reference in New Issue
Block a user