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:
MythEclipse
2025-07-21 21:29:04 +07:00
parent e66f1f1634
commit 1a2e0c58b6
103 changed files with 7851 additions and 1509 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ use super::Env;
use axum::http::StatusCode;
use chrono::{Duration, TimeDelta, Utc};
use jsonwebtoken::{
decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation,
DecodingKey, EncodingKey, Header, TokenData, Validation, decode, encode,
};
use serde::{Deserialize, Serialize};
@@ -51,7 +51,7 @@ pub fn decode_access_token(
let env = Env::new();
let secret: String = env.access_token_secret;
let result: Result<TokenData<Claims>, StatusCode> = decode(
&jwt_token,
jwt_token,
&DecodingKey::from_secret(secret.as_ref()),
&Validation::default(),
)
@@ -81,7 +81,7 @@ pub fn decode_refresh_token(
let env = Env::new();
let secret: String = env.refresh_token_secret;
let result: Result<TokenData<Claims>, StatusCode> = decode(
&jwt_token,
jwt_token,
&DecodingKey::from_secret(secret.as_ref()),
&Validation::default(),
)