feat: search repositories

This commit is contained in:
Aravinth Manivannan 2023-02-23 13:03:58 +05:30
parent 359c0133b8
commit 0e040e4875
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 10 additions and 0 deletions

View file

@ -217,6 +217,9 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
/// add new repository to database.
async fn create_repository(&self, r: &AddRepository) -> DBResult<()>;
/// Search all repositories
async fn search_repository(&self, query: &str) -> DBResult<Vec<Repository>>;
}
/// Trait to clone SCDatabase

View file

@ -81,6 +81,13 @@ pub async fn adding_forge_works<'a, T: SCDatabase>(
.repository_exists(add_repo_msg.name, add_repo_msg.owner, &add_repo_msg.url)
.await
.unwrap());
assert!(db.get_all_repositories(00, 1000).await.unwrap().len() >= 1);
let repo_search = db.search_repository(add_repo_msg.name).await.unwrap();
assert!(!repo_search.is_empty());
assert_eq!(repo_search.first().unwrap().url, add_repo_msg.url.as_str());
// delete repository
db.delete_repository(add_repo_msg.owner, add_repo_msg.name, &add_repo_msg.url)
.await