feat: def get_forge interface

This commit is contained in:
Aravinth Manivannan 2022-06-03 23:05:09 +05:30
parent 036a90e74a
commit 7b343a2cd5
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 20 additions and 0 deletions

View file

@ -107,6 +107,17 @@ pub struct AddRepository<'a> {
pub website: Option<&'a str>, pub website: Option<&'a str>,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
/// data representing a forge instance
pub struct Forge {
/// hostname of the forge
pub hostname: String,
/// type of the forge
pub forge_type: ForgeImplementation,
/// last crawl
pub last_crawl_on: Option<i64>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
/// repository /// repository
pub struct Repository { pub struct Repository {
@ -160,6 +171,9 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
/// create forge isntance /// create forge isntance
async fn create_forge_isntance(&self, f: &CreateForge) -> DBResult<()>; async fn create_forge_isntance(&self, f: &CreateForge) -> DBResult<()>;
/// get forge isntance data
async fn get_forge(&self, hostname: &str) -> DBResult<Forge>;
/// delete forge isntance /// delete forge isntance
async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()>; async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()>;

View file

@ -33,6 +33,12 @@ pub async fn adding_forge_works<'a, T: SCDatabase>(
"forge creation failed, forge existance check failure" "forge creation failed, forge existance check failure"
); );
{
let forge = db.get_forge(create_forge_msg.hostname).await.unwrap();
assert_eq!(forge.hostname, create_forge_msg.hostname);
assert_eq!(forge.forge_type, create_forge_msg.forge_type);
}
// add user // add user
db.add_user(&add_user_msg).await.unwrap(); db.add_user(&add_user_msg).await.unwrap();
db.add_user(&add_user_msg2).await.unwrap(); db.add_user(&add_user_msg2).await.unwrap();