From e2cf9460e52257e8990744285b31cab31d245df9 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 4 Jun 2022 20:45:01 +0530 Subject: [PATCH] feat: def interface to check if user exists --- federate/federate-core/src/lib.rs | 3 +++ federate/federate-core/src/tests.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/federate/federate-core/src/lib.rs b/federate/federate-core/src/lib.rs index 612291b..b96250b 100644 --- a/federate/federate-core/src/lib.rs +++ b/federate/federate-core/src/lib.rs @@ -45,6 +45,9 @@ pub trait Federate: Sync + Send { /// check if a forge instance exists async fn forge_exists(&self, hostname: &str) -> Result; + /// check if an user exists. + async fn user_exists(&self, username: &str, hostname: &str) -> Result; + /// create user isntance async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error>; diff --git a/federate/federate-core/src/tests.rs b/federate/federate-core/src/tests.rs index 1c0a229..d966c7a 100644 --- a/federate/federate-core/src/tests.rs +++ b/federate/federate-core/src/tests.rs @@ -29,8 +29,17 @@ pub async fn adding_forge_works<'a, T: Federate>( assert!(!ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); ff.create_forge_isntance(&create_forge_msg).await.unwrap(); assert!(ff.forge_exists(&create_forge_msg.hostname).await.unwrap()); + // add user + assert!(!ff + .user_exists(&create_user_msg.username, &create_user_msg.hostname) + .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 ff.create_repository(&add_repo_msg).await.unwrap();