feat: def get_forge interface
This commit is contained in:
parent
036a90e74a
commit
7b343a2cd5
2 changed files with 20 additions and 0 deletions
|
@ -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<i64>,
|
||||
}
|
||||
|
||||
#[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<Forge>;
|
||||
|
||||
/// delete forge isntance
|
||||
async fn delete_forge_instance(&self, hostname: &str) -> DBResult<()>;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue