diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index 6ff0b21..3147684 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -107,6 +107,17 @@ pub struct AddRepository<'a> { 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, +} + #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] /// repository pub struct Repository { @@ -160,6 +171,9 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { /// create forge isntance async fn create_forge_isntance(&self, f: &CreateForge) -> DBResult<()>; + /// get forge isntance data + async fn get_forge(&self, hostname: &str) -> DBResult; + /// delete forge isntance async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()>; diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index 2ad629d..6258770 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -33,6 +33,12 @@ pub async fn adding_forge_works<'a, T: SCDatabase>( "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 db.add_user(&add_user_msg).await.unwrap(); db.add_user(&add_user_msg2).await.unwrap();