feat: add tests to check if forge type is loaded into DB

This commit is contained in:
Aravinth Manivannan 2022-04-12 17:44:21 +05:30
parent 2a8283acc0
commit 99fabab5bc
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 16 additions and 0 deletions

View file

@ -81,6 +81,9 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
/// check if a forge instance exists /// check if a forge instance exists
async fn forge_exists(&self, hostname: &str) -> DBResult<bool>; async fn forge_exists(&self, hostname: &str) -> DBResult<bool>;
/// check if forge type exists
async fn forge_type_exists(&self, forge_type: &ForgeImplementation) -> DBResult<bool>;
} }
/// Trait to clone SCDatabase /// Trait to clone SCDatabase

View file

@ -27,3 +27,16 @@ pub async fn adding_forge_works<T: SCDatabase>(
db.create_forge_isntance(&create_forge_msg).await.unwrap(); 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"); 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<T: SCDatabase>(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());
}
}