From 76cd9a0fd60200f34afd53a2e2fcb6d776d850b5 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 4 Jun 2022 21:29:59 +0530 Subject: [PATCH] feat: def interface to check if repository exists --- federate/federate-core/src/lib.rs | 8 ++++++++ federate/federate-core/src/tests.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/federate/federate-core/src/lib.rs b/federate/federate-core/src/lib.rs index b96250b..bad7f94 100644 --- a/federate/federate-core/src/lib.rs +++ b/federate/federate-core/src/lib.rs @@ -54,6 +54,14 @@ pub trait Federate: Sync + Send { /// add repository isntance async fn create_repository(&self, f: &AddRepository<'_>) -> Result<(), Self::Error>; + /// check if a repository exists. + async fn repository_exists( + &self, + name: &str, + owner: &str, + hostname: &str, + ) -> Result; + /// delete user async fn delete_user(&self, username: &str, hostname: &str) -> Result<(), Self::Error>; diff --git a/federate/federate-core/src/tests.rs b/federate/federate-core/src/tests.rs index d966c7a..df9a268 100644 --- a/federate/federate-core/src/tests.rs +++ b/federate/federate-core/src/tests.rs @@ -42,7 +42,15 @@ pub async fn adding_forge_works<'a, T: Federate>( .unwrap()); // add repository + assert!(!ff + .repository_exists(add_repo_msg.name, add_repo_msg.owner, add_repo_msg.hostname) + .await + .unwrap()); ff.create_repository(&add_repo_msg).await.unwrap(); + assert!(ff + .repository_exists(add_repo_msg.name, add_repo_msg.owner, add_repo_msg.hostname) + .await + .unwrap()); // tar() ff.tar().await.unwrap();