feat: def interface to get all forges
This commit is contained in:
parent
ef2707e4ee
commit
1ec46670ec
2 changed files with 16 additions and 1 deletions
|
@ -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<bool>;
|
||||
|
||||
/// Get all forges
|
||||
async fn get_all_forges(&self, offset: u32, limit: u32) -> DBResult<Vec<Forge>>;
|
||||
|
||||
/// 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<bool>;
|
||||
|
||||
/// Get all repositories
|
||||
async fn get_all_repositories(&self, page: u32, limit: u32) -> DBResult<Vec<Repository>>;
|
||||
async fn get_all_repositories(&self, offset: u32, limit: u32) -> DBResult<Vec<Repository>>;
|
||||
|
||||
/// add new repository to database.
|
||||
async fn create_repository(&self, r: &AddRepository) -> DBResult<()>;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue