Files
schedule-parser-rusted/src/test_env.rs
n08i40k e64011ba16 feat!: add telegram auth and async refactor
- Removed "/schedule/update-download-url" endpoint, this mechanism was replaced by Yandex Cloud FaaS. Ура :)
- Improved schedule caching mechanism.
- Added Telegram WebApp authentication support.
- Reworked endpoints responses and errors mechanism.
- Refactored application state management.
- Make synchronous database operations, middlewares and extractors to asynchronous.
- Made user password field optional to support multiple auth methods.
- Renamed users table column "version" to "android_version" and made it nullable.
2025-06-08 01:43:45 +04:00

34 lines
1023 B
Rust

#[cfg(test)]
pub(crate) mod tests {
use crate::state::{AppState, ScheduleSnapshot, new_app_state};
use actix_web::web;
use log::info;
use schedule_parser::test_utils::test_result;
use std::default::Default;
use tokio::sync::OnceCell;
pub fn test_env() {
info!("Loading test environment file...");
dotenvy::from_path(".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();
state.get_schedule().await.snapshot.write(ScheduleSnapshot {
fetched_at: Default::default(),
updated_at: Default::default(),
url: "".to_string(),
data: test_result().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()
}
}