From 0d0f5270fd0dda48df34b3df87964e44360d3c1b Mon Sep 17 00:00:00 2001 From: realaravinth Date: Fri, 3 Jun 2022 23:10:31 +0530 Subject: [PATCH] feat: def forge_exists interface --- federate/federate-core/src/lib.rs | 3 +++ federate/federate-core/src/tests.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/federate/federate-core/src/lib.rs b/federate/federate-core/src/lib.rs index ed59f39..612291b 100644 --- a/federate/federate-core/src/lib.rs +++ b/federate/federate-core/src/lib.rs @@ -42,6 +42,9 @@ pub trait Federate: Sync + Send { /// delete forge isntance async fn delete_forge_instance(&self, hostname: &str) -> Result<(), Self::Error>; + /// check if a forge instance exists + async fn forge_exists(&self, 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 db20111..1c0a229 100644 --- a/federate/federate-core/src/tests.rs +++ b/federate/federate-core/src/tests.rs @@ -26,7 +26,9 @@ pub async fn adding_forge_works<'a, T: Federate>( add_repo_msg: AddRepository<'a>, ) { let _ = ff.delete_forge_instance(create_forge_msg.hostname).await; + 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 ff.create_user(&create_user_msg).await.unwrap();