mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 09:47:50 +03:00
0.4.0
Авторизация через токен вк Слияние schedule_parser с проектом Перенос схемы запросов/ответов в файлы эндпоинтов Переход с библиотеки jwt на jsonwebtokens
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use crate::app_state::{AppState, app_state};
|
||||
use crate::app_state::{app_state, AppState, Schedule};
|
||||
use actix_web::dev::{HttpServiceFactory, Service, ServiceResponse};
|
||||
use actix_web::{App, test, web};
|
||||
use actix_web::{test, web, App};
|
||||
use std::sync::LazyLock;
|
||||
use crate::parser::tests::test_result;
|
||||
|
||||
pub fn test_env() {
|
||||
dotenvy::from_path(".env.test").expect("Failed to load test environment file");
|
||||
@@ -19,8 +20,22 @@ pub(crate) mod tests {
|
||||
test::init_service(App::new().app_data(app_state).service(factory)).await
|
||||
}
|
||||
|
||||
pub fn test_app_state() -> web::Data<AppState> {
|
||||
let state = app_state();
|
||||
let mut schedule_lock = state.schedule.lock().unwrap();
|
||||
|
||||
*schedule_lock = Some(Schedule {
|
||||
etag: "".to_string(),
|
||||
updated_at: Default::default(),
|
||||
parsed_at: Default::default(),
|
||||
data: test_result(),
|
||||
});
|
||||
|
||||
state.clone()
|
||||
}
|
||||
|
||||
pub fn static_app_state() -> web::Data<AppState> {
|
||||
static STATE: LazyLock<web::Data<AppState>> = LazyLock::new(|| app_state());
|
||||
static STATE: LazyLock<web::Data<AppState>> = LazyLock::new(|| test_app_state());
|
||||
|
||||
STATE.clone()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user