feat: define interface to del user and repository
This commit is contained in:
parent
dcb11a4d11
commit
5481055e45
2 changed files with 37 additions and 0 deletions
|
@ -133,6 +133,12 @@ pub trait SCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||
/// done only on that forge
|
||||
async fn user_exists(&self, username: &str, hostname: Option<&str>) -> DBResult<bool>;
|
||||
|
||||
/// delete user
|
||||
async fn delete_user(&self, username: &str, hostname: &str) -> DBResult<()>;
|
||||
|
||||
/// delete repository
|
||||
async fn delete_repository(&self, owner: &str, name: &str, hostname: &str) -> DBResult<()>;
|
||||
|
||||
/// check if a repository exists.
|
||||
async fn repository_exists(&self, name: &str, owner: &str, hostname: &str) -> DBResult<bool>;
|
||||
|
||||
|
|
|
@ -33,9 +33,40 @@ pub async fn adding_forge_works<'a, T: SCDatabase>(
|
|||
"forge creation failed, forge existance check failure"
|
||||
);
|
||||
|
||||
// add user
|
||||
db.add_user(&add_user_msg).await.unwrap();
|
||||
db.add_user(&add_user_msg2).await.unwrap();
|
||||
// verify user exists
|
||||
assert!(db.user_exists(add_user_msg.username, None).await.unwrap());
|
||||
assert!(db
|
||||
.user_exists(add_user_msg.username, Some(add_user_msg.hostname))
|
||||
.await
|
||||
.unwrap());
|
||||
|
||||
// add repository
|
||||
db.create_repository(&add_repo_msg).await.unwrap();
|
||||
// verify repo exists
|
||||
assert!(db
|
||||
.repository_exists(add_repo_msg.name, add_repo_msg.owner, add_repo_msg.hostname)
|
||||
.await
|
||||
.unwrap());
|
||||
// delete repository
|
||||
db.delete_repository(add_repo_msg.owner, add_repo_msg.name, add_repo_msg.hostname)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(!db
|
||||
.repository_exists(add_repo_msg.name, add_repo_msg.owner, add_repo_msg.hostname)
|
||||
.await
|
||||
.unwrap());
|
||||
|
||||
// delete user
|
||||
db.delete_user(add_user_msg.username, add_user_msg.hostname)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(!db
|
||||
.user_exists(add_user_msg.username, Some(add_user_msg.hostname))
|
||||
.await
|
||||
.unwrap());
|
||||
}
|
||||
|
||||
/// test if all forge type implementations are loaded into DB
|
||||
|
|
Loading…
Reference in a new issue