Files
imphnen-backend-service/tests/src/lib.rs
T

29 lines
639 B
Rust
Raw Normal View History

2025-05-22 00:31:36 +07:00
use ::surrealdb::Uuid;
2025-04-06 22:13:46 +07:00
pub use imphnen_entities::*;
2025-05-17 02:08:59 +07:00
pub use imphnen_iam::*;
2025-04-06 22:13:46 +07:00
#[cfg(test)]
2025-05-17 02:08:59 +07:00
pub mod iam;
2025-05-22 00:31:36 +07:00
pub fn generate_unique_email(prefix: &str) -> String {
format!("{}_{}@example.com", prefix, Uuid::new_v4())
}
pub async fn get_role_id(state: &crate::AppState) -> String {
let repo = RolesRepository::new(state);
if let Ok(existing) = repo.query_role_by_name("User".into()).await {
return existing.id;
}
let _ = repo
.query_create_role(RolesRequestCreateDto {
name: "User".into(),
permissions: vec![],
})
.await;
repo
.query_role_by_name("User".into())
.await
.expect("Role not found after creation")
.id
}