From 99fabab5bcab4a0445da4f2a7e399a16267a4c13 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Tue, 12 Apr 2022 17:44:21 +0530 Subject: [PATCH] feat: add tests to check if forge type is loaded into DB --- db/db-core/src/lib.rs | 3 +++ db/db-core/src/tests.rs | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index cd2646c..91bfdb4 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -81,6 +81,9 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { /// check if a forge instance exists async fn forge_exists(&self, hostname: &str) -> DBResult; + + /// check if forge type exists + async fn forge_type_exists(&self, forge_type: &ForgeImplementation) -> DBResult; } /// Trait to clone SCDatabase diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index 41a1968..99195df 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -27,3 +27,16 @@ pub async fn adding_forge_works( db.create_forge_isntance(&create_forge_msg).await.unwrap(); assert!(db.forge_exists(create_forge_msg.hostname).await.unwrap(), "forge creation failed, forge existance check failure"); } + + +/// test if all forge type implementations are loaded into DB +pub async fn forge_type_exists_helper(db: &T) { + for f in [ + ForgeImplementation::Gitea + ] + .iter() + { + println!("Testing forge implementation exists for: {}", f.to_str()); + assert!(db.forge_type_exists(f).await.unwrap()); + } +}