mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-18 05:51:17 +00:00
feat: test put_user_data
This commit is contained in:
parent
713d978f2c
commit
2bd112beb8
1 changed files with 28 additions and 0 deletions
|
|
@ -137,10 +137,13 @@ impl CandidateService {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use chrono::NaiveDate;
|
||||
use sea_orm::{Database, DbConn};
|
||||
|
||||
use crate::{crypto, services::candidate_service::CandidateService};
|
||||
|
||||
use super::AddUserDetailsForm;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_application_id_validation() {
|
||||
assert!(CandidateService::is_application_id_valid(101_101));
|
||||
|
|
@ -188,4 +191,29 @@ mod tests {
|
|||
assert_eq!(secret_message, decrypted_message);
|
||||
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_put_user_data() {
|
||||
let db = get_memory_sqlite_connection().await;
|
||||
let plain_text_password = "test".to_string();
|
||||
let candidate = CandidateService::create(&db, 103151, &plain_text_password, "".to_string()).await.ok().unwrap();
|
||||
|
||||
let form = AddUserDetailsForm {
|
||||
application_id: candidate.application,
|
||||
name: "test".to_string(),
|
||||
surname: "a".to_string(),
|
||||
birthplace: "b".to_string(),
|
||||
birthdate: NaiveDate::from_ymd(1999, 1, 1),
|
||||
address: "test".to_string(),
|
||||
telephone: "test".to_string(),
|
||||
citizenship: "test".to_string(),
|
||||
email: "test".to_string(),
|
||||
sex: "test".to_string(),
|
||||
study: "test".to_string(),
|
||||
};
|
||||
|
||||
let candidate = CandidateService::add_user_details(&db, form).await.ok().unwrap();
|
||||
|
||||
assert!(candidate.name.is_some());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue