feat: add tests to check for forge types in DB

This commit is contained in:
Aravinth Manivannan 2022-04-12 17:47:34 +05:30
parent e124cb6348
commit d3d2abf074
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88

View file

@ -19,23 +19,18 @@
use crate::prelude::*; use crate::prelude::*;
/// adding forge works /// adding forge works
pub async fn adding_forge_works<T: SCDatabase>( pub async fn adding_forge_works<T: SCDatabase>(db: &T, create_forge_msg: CreateForge<'static>) {
db: &T, let _ = db.delete_forge_instance(&create_forge_msg.hostname).await;
create_forge_msg: CreateForge<'static> db.create_forge_isntance(&create_forge_msg).await.unwrap();
) { assert!(
let _ = db.delete_forge_instance(&create_forge_msg.hostname).await; db.forge_exists(create_forge_msg.hostname).await.unwrap(),
db.create_forge_isntance(&create_forge_msg).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 /// test if all forge type implementations are loaded into DB
pub async fn forge_type_exists_helper<T: SCDatabase>(db: &T) { pub async fn forge_type_exists_helper<T: SCDatabase>(db: &T) {
for f in [ for f in [ForgeImplementation::Gitea].iter() {
ForgeImplementation::Gitea
]
.iter()
{
println!("Testing forge implementation exists for: {}", f.to_str()); println!("Testing forge implementation exists for: {}", f.to_str());
assert!(db.forge_type_exists(f).await.unwrap()); assert!(db.forge_type_exists(f).await.unwrap());
} }