mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-11-23 22:15:46 +00:00
feat: add checks to verify the DB error situations
This commit is contained in:
parent
d5b17ac00e
commit
337a378b08
@ -28,6 +28,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
an: &AddNotification<'a>,
|
an: &AddNotification<'a>,
|
||||||
) {
|
) {
|
||||||
assert!(db.ping().await, "ping test");
|
assert!(db.ping().await, "ping test");
|
||||||
|
|
||||||
if db.username_exists(p.username).await.unwrap() {
|
if db.username_exists(p.username).await.unwrap() {
|
||||||
db.delete_user(p.username).await.unwrap();
|
db.delete_user(p.username).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
@ -35,14 +36,23 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
"user is deleted so username shouldn't exsit"
|
"user is deleted so username shouldn't exsit"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
db.get_secret(&p.username).await,
|
||||||
|
Err(DBError::AccountNotFound)
|
||||||
|
));
|
||||||
|
|
||||||
db.register(p).await.unwrap();
|
db.register(p).await.unwrap();
|
||||||
|
|
||||||
|
assert!(matches!(db.register(&p).await, Err(DBError::UsernameTaken)));
|
||||||
|
|
||||||
// testing get secret
|
// testing get secret
|
||||||
let secret = db.get_secret(p.username).await.unwrap();
|
let secret = db.get_secret(p.username).await.unwrap();
|
||||||
assert_eq!(secret.secret, p.secret, "user secret matches");
|
assert_eq!(secret.secret, p.secret, "user secret matches");
|
||||||
|
|
||||||
// testing update secret: setting secret = username
|
// testing update secret: setting secret = username
|
||||||
db.update_secret(p.username, p.username).await.unwrap();
|
db.update_secret(p.username, p.username).await.unwrap();
|
||||||
|
|
||||||
let secret = db.get_secret(p.username).await.unwrap();
|
let secret = db.get_secret(p.username).await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
secret.secret, p.username,
|
secret.secret, p.username,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user