feat: add checks to verify the DB error situations
This commit is contained in:
parent
d5b17ac00e
commit
337a378b08
1 changed files with 10 additions and 0 deletions
|
@ -28,6 +28,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
an: &AddNotification<'a>,
|
||||
) {
|
||||
assert!(db.ping().await, "ping test");
|
||||
|
||||
if db.username_exists(p.username).await.unwrap() {
|
||||
db.delete_user(p.username).await.unwrap();
|
||||
assert!(
|
||||
|
@ -35,14 +36,23 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
"user is deleted so username shouldn't exsit"
|
||||
);
|
||||
}
|
||||
|
||||
assert!(matches!(
|
||||
db.get_secret(&p.username).await,
|
||||
Err(DBError::AccountNotFound)
|
||||
));
|
||||
|
||||
db.register(p).await.unwrap();
|
||||
|
||||
assert!(matches!(db.register(&p).await, Err(DBError::UsernameTaken)));
|
||||
|
||||
// testing get secret
|
||||
let secret = db.get_secret(p.username).await.unwrap();
|
||||
assert_eq!(secret.secret, p.secret, "user secret matches");
|
||||
|
||||
// testing update secret: setting secret = username
|
||||
db.update_secret(p.username, p.username).await.unwrap();
|
||||
|
||||
let secret = db.get_secret(p.username).await.unwrap();
|
||||
assert_eq!(
|
||||
secret.secret, p.username,
|
||||
|
|
Loading…
Reference in a new issue