mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 09:47:50 +03:00
feat(database)!: switch from diesel to sea-orm
This commit is contained in:
@@ -7,20 +7,31 @@ pub(crate) mod tests {
|
||||
|
||||
pub fn test_env() {
|
||||
info!("Loading test environment file...");
|
||||
|
||||
dotenvy::from_filename(".env.test.local")
|
||||
.or_else(|_| dotenvy::from_filename(".env.test"))
|
||||
.expect("Failed to load test environment file");
|
||||
}
|
||||
|
||||
pub async fn test_app_state() -> web::Data<AppState> {
|
||||
let state = new_app_state().await.unwrap();
|
||||
let state = new_app_state(Some(static_app_state().await.get_database().clone()))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
state.clone()
|
||||
}
|
||||
|
||||
pub async fn static_app_state() -> web::Data<AppState> {
|
||||
static STATE: OnceCell<web::Data<AppState>> = OnceCell::const_new();
|
||||
|
||||
STATE.get_or_init(|| test_app_state()).await.clone()
|
||||
|
||||
STATE
|
||||
.get_or_init(async || -> web::Data<AppState> {
|
||||
#[cfg(all(test, tokio_unstable))]
|
||||
console_subscriber::init();
|
||||
|
||||
new_app_state(None).await.unwrap()
|
||||
})
|
||||
.await
|
||||
.clone()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user