diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index 5639a24..cc838cf 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -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>; } /// Trait to clone SCDatabase diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index 7eee390..bfb64d5 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -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