From 1ec46670ec3fd42f907283f49539899197d3fd67 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Thu, 9 Jun 2022 14:36:22 +0530 Subject: [PATCH] feat: def interface to get all forges --- db/db-core/src/lib.rs | 5 ++++- db/db-core/src/tests.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index bdf79dd..457189e 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -197,6 +197,9 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { /// check if forge type exists async fn forge_type_exists(&self, forge_type: &ForgeImplementation) -> DBResult; + /// Get all forges + async fn get_all_forges(&self, offset: u32, limit: u32) -> DBResult>; + /// add new user to database async fn add_user(&self, u: &AddUser) -> DBResult<()>; @@ -217,7 +220,7 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { async fn repository_exists(&self, name: &str, owner: &str, hostname: &str) -> DBResult; /// Get all repositories - async fn get_all_repositories(&self, page: u32, limit: u32) -> DBResult>; + async fn get_all_repositories(&self, offset: u32, limit: u32) -> DBResult>; /// add new repository to database. async fn create_repository(&self, r: &AddRepository) -> DBResult<()>; diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index c347374..eb3ee3a 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -35,6 +35,18 @@ pub async fn adding_forge_works<'a, T: SCDatabase>( { let forge = db.get_forge(create_forge_msg.hostname).await.unwrap(); + let forges = db.get_all_forges(0, 10).await.unwrap(); + assert_eq!(forges.len(), 1); + + assert_eq!( + forges.get(0).as_ref().unwrap().forge_type, + create_forge_msg.forge_type + ); + assert_eq!( + forges.get(0).as_ref().unwrap().hostname, + create_forge_msg.hostname + ); + assert_eq!(forge.hostname, create_forge_msg.hostname); assert_eq!(forge.forge_type, create_forge_msg.forge_type); }