meta db unit tests and fixes

This commit is contained in:
Scott E. Graves 2024-12-04 13:56:06 -06:00
parent b4621f6a4e
commit 1d7d221da1

View File

@ -49,6 +49,32 @@ TYPED_TEST(meta_db_test, can_get_api_path_from_source_path) {
EXPECT_STREQ(test_file.c_str(), api_path.c_str());
}
TYPED_TEST(meta_db_test, can_change_source_path) {
auto test_file = create_test_file();
auto test_source = create_test_file();
auto test_source2 = create_test_file();
EXPECT_EQ(
api_error::success,
this->meta_db->set_item_meta(
test_file, {
{META_DIRECTORY, utils::string::from_bool(false)},
{META_SOURCE, test_source},
}));
EXPECT_EQ(api_error::success,
this->meta_db->set_item_meta(test_file, META_SOURCE, test_source2));
std::string api_path;
EXPECT_EQ(api_error::success,
this->meta_db->get_api_path(test_source2, api_path));
EXPECT_STREQ(test_file.c_str(), api_path.c_str());
std::string api_path2;
EXPECT_EQ(api_error::item_not_found,
this->meta_db->get_api_path(test_source, api_path2));
EXPECT_TRUE(api_path2.empty());
}
TYPED_TEST(meta_db_test,
get_api_path_return_item_not_found_if_source_does_not_exist) {
std::string api_path;