feat: def interface to check if user exists

This commit is contained in:
Aravinth Manivannan 2022-06-04 20:45:01 +05:30
parent 3edafd4f6d
commit e2cf9460e5
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 12 additions and 0 deletions

View file

@ -45,6 +45,9 @@ pub trait Federate: Sync + Send {
/// check if a forge instance exists /// check if a forge instance exists
async fn forge_exists(&self, hostname: &str) -> Result<bool, Self::Error>; async fn forge_exists(&self, hostname: &str) -> Result<bool, Self::Error>;
/// check if an user exists.
async fn user_exists(&self, username: &str, hostname: &str) -> Result<bool, Self::Error>;
/// create user isntance /// create user isntance
async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error>; async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error>;

View file

@ -29,8 +29,17 @@ pub async fn adding_forge_works<'a, T: Federate>(
assert!(!ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); assert!(!ff.forge_exists(&create_forge_msg.hostname).await.unwrap());
ff.create_forge_isntance(&create_forge_msg).await.unwrap(); ff.create_forge_isntance(&create_forge_msg).await.unwrap();
assert!(ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); assert!(ff.forge_exists(&create_forge_msg.hostname).await.unwrap());
// add user // add user
assert!(!ff
.user_exists(&create_user_msg.username, &create_user_msg.hostname)
.await
.unwrap());
ff.create_user(&create_user_msg).await.unwrap(); ff.create_user(&create_user_msg).await.unwrap();
assert!(ff
.user_exists(&create_user_msg.username, &create_user_msg.hostname)
.await
.unwrap());
// add repository // add repository
ff.create_repository(&add_repo_msg).await.unwrap(); ff.create_repository(&add_repo_msg).await.unwrap();