chore: better error handling for accepting invitation

This commit is contained in:
Zack Fu Zi Xiang 2024-03-04 20:55:57 +08:00
parent 9dc61bec31
commit f70995ad05
No known key found for this signature in database
2 changed files with 17 additions and 2 deletions

View File

@ -204,6 +204,9 @@ impl TestClient {
.api_client
.accept_workspace_invitation(target_invitation.invite_id.to_string().as_str())
.await
.unwrap();
Ok(())
}
pub async fn try_remove_workspace_member(

View File

@ -286,8 +286,20 @@ pub async fn update_workspace_invitation_set_invited(
)
.execute(txn.deref_mut())
.await?;
assert_eq!(res.rows_affected(), 1);
Ok(())
match res.rows_affected() {
0 => Err(AppError::RecordNotFound(format!(
"Invitation not found, invitee_uuid: {}, invite_id: {}",
invitee_uuid, invite_id
))),
1 => Ok(()),
x => Err(
anyhow::anyhow!(
"Expected 1 row to be affected, but {} rows were affected",
x
)
.into(),
),
}
}
pub async fn get_invitation_by_id(