Add comprehensive tests for mentor repository and authentication
- Implemented tests for creating, retrieving, updating, and deleting mentors in `mentor_repository_test.rs`. - Added tests for user authentication, including successful login, invalid email formats, and inactive users in `auth_login_tests.rs`. - Created a mock test environment setup in `mock_test.rs` to facilitate database operations during tests. - Updated module structure to include new test files for mentors and authentication. - Ensured cleanup of the database after tests to maintain isolation and prevent side effects.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use super::Env;
|
||||
use crate::SurrealMemClient;
|
||||
use surrealdb::engine::local::Mem;
|
||||
use crate::enviroment::load_env;
|
||||
use surrealdb::engine::any;
|
||||
use surrealdb::engine::local::Mem;
|
||||
use surrealdb::opt::auth::Root;
|
||||
use surrealdb::{Result, Surreal};
|
||||
use crate::enviroment::load_env;
|
||||
|
||||
pub mod resource;
|
||||
pub use resource::*;
|
||||
@@ -13,7 +13,6 @@ pub async fn surrealdb_init_ws() -> Result<Surreal<any::Any>> {
|
||||
load_env();
|
||||
let env = Env::new();
|
||||
let db = any::connect(&env.surrealdb_url).await?;
|
||||
|
||||
|
||||
db.signin(Root {
|
||||
username: &env.surrealdb_username,
|
||||
|
||||
@@ -14,6 +14,7 @@ pub enum ResourceEnum {
|
||||
RolesPermissions,
|
||||
Events,
|
||||
Testimonials,
|
||||
Mentors,
|
||||
}
|
||||
|
||||
impl fmt::Display for ResourceEnum {
|
||||
@@ -31,7 +32,8 @@ impl fmt::Display for ResourceEnum {
|
||||
ResourceEnum::GachaCredits => "app_gacha_credits",
|
||||
ResourceEnum::Events => "app_events",
|
||||
ResourceEnum::Testimonials => "app_testimonials",
|
||||
ResourceEnum::Mentors => "app_mentors",
|
||||
};
|
||||
write!(f, "{}", str)
|
||||
write!(f, "{str}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user