mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-27 05:51:56 +00:00
fix: find session test
This commit is contained in:
parent
95aa99cfa1
commit
24d385bbdf
1 changed files with 18 additions and 22 deletions
|
|
@ -32,7 +32,8 @@ impl Query {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use entity::{session};
|
use entity::{session, admin, candidate};
|
||||||
|
use sea_orm::ActiveValue::NotSet;
|
||||||
use sea_orm::{prelude::Uuid, ActiveModelTrait, Set};
|
use sea_orm::{prelude::Uuid, ActiveModelTrait, Set};
|
||||||
|
|
||||||
use crate::utils::db::get_memory_sqlite_connection;
|
use crate::utils::db::get_memory_sqlite_connection;
|
||||||
|
|
@ -57,8 +58,7 @@ mod tests {
|
||||||
assert!(session.is_some());
|
assert!(session.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Opravit test_find_sessions_by_user_id
|
#[tokio::test]
|
||||||
/* #[tokio::test]
|
|
||||||
async fn test_find_sessions_by_user_id() {
|
async fn test_find_sessions_by_user_id() {
|
||||||
let db = get_memory_sqlite_connection().await;
|
let db = get_memory_sqlite_connection().await;
|
||||||
|
|
||||||
|
|
@ -69,14 +69,14 @@ mod tests {
|
||||||
code: Set("test".to_string()),
|
code: Set("test".to_string()),
|
||||||
public_key: Set("test".to_string()),
|
public_key: Set("test".to_string()),
|
||||||
private_key: Set("test".to_string()),
|
private_key: Set("test".to_string()),
|
||||||
personal_identification_number_hash: Set("test".to_string()),
|
personal_identification_number: Set("test".to_string()),
|
||||||
created_at: Set(chrono::offset::Local::now().naive_local()),
|
created_at: Set(chrono::offset::Local::now().naive_local()),
|
||||||
updated_at: Set(chrono::offset::Local::now().naive_local()),
|
updated_at: Set(chrono::offset::Local::now().naive_local()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.insert(&db)
|
.insert(&db)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
session::ActiveModel {
|
session::ActiveModel {
|
||||||
id: Set(Uuid::new_v4()),
|
id: Set(Uuid::new_v4()),
|
||||||
|
|
@ -87,9 +87,9 @@ mod tests {
|
||||||
expires_at: Set(chrono::offset::Local::now().naive_local()),
|
expires_at: Set(chrono::offset::Local::now().naive_local()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.insert(&db)
|
.insert(&db)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
const ADMIN_ID: i32 = 1;
|
const ADMIN_ID: i32 = 1;
|
||||||
|
|
||||||
|
|
@ -103,9 +103,9 @@ mod tests {
|
||||||
updated_at: Set(chrono::offset::Local::now().naive_local()),
|
updated_at: Set(chrono::offset::Local::now().naive_local()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.insert(&db)
|
.insert(&db)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
session::ActiveModel {
|
session::ActiveModel {
|
||||||
id: Set(Uuid::new_v4()),
|
id: Set(Uuid::new_v4()),
|
||||||
|
|
@ -116,18 +116,14 @@ mod tests {
|
||||||
expires_at: Set(chrono::offset::Local::now().naive_local()),
|
expires_at: Set(chrono::offset::Local::now().naive_local()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.insert(&db)
|
.insert(&db)
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let sessions = Query::find_sessions_by_user_id(&db, Some(APPLICATION_ID), None)
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let sessions = Query::find_sessions_by_user_id(&db, Some(APPLICATION_ID), None).await.unwrap();
|
||||||
assert_eq!(sessions.len(), 1);
|
assert_eq!(sessions.len(), 1);
|
||||||
|
|
||||||
let sessions = Query::find_sessions_by_user_id(&db, None, Some(ADMIN_ID))
|
let sessions = Query::find_sessions_by_user_id(&db, None, Some(ADMIN_ID)).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(sessions.len(), 1);
|
assert_eq!(sessions.len(), 1);
|
||||||
} */
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue