-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use async_trait::async_trait; | ||
use mensa_app_backend::{ | ||
interface::image_review::ImageReviewScheduling, | ||
layer::{ | ||
data::{ | ||
database::factory::DataAccessFactory, swka_parser::swka_parse_manager::SwKaParseManager, | ||
}, | ||
logic::mealplan_management::meal_plan_manager::MealPlanManager, | ||
trigger::scheduling::scheduler::{ScheduleInfo, Scheduler}, | ||
}, | ||
startup::config::ConfigReader, | ||
}; | ||
use tokio::signal::ctrl_c; | ||
|
||
#[tokio::test] | ||
async fn test_full_mensa_parse_scheduling() { | ||
let info = ScheduleInfo { | ||
full_parse_schedule: "0 */5 * * * *".to_string(), | ||
update_parse_schedule: "* * * * 0 *".to_string(), | ||
image_review_schedule: "* * * * 0 *".to_string(), | ||
}; | ||
let mut scheduler = setup(info).await; | ||
scheduler.start().await; | ||
ctrl_c().await.unwrap(); | ||
scheduler.shutdown().await; | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_update_mensa_parse_scheduling() { | ||
let info = ScheduleInfo { | ||
full_parse_schedule: "* * * * 0 *".to_string(), | ||
update_parse_schedule: "0 */5 * * * *".to_string(), | ||
image_review_schedule: "* * * * 0 *".to_string(), | ||
}; | ||
let mut scheduler = setup(info).await; | ||
scheduler.start().await; | ||
ctrl_c().await.unwrap(); | ||
scheduler.shutdown().await; | ||
} | ||
|
||
async fn setup(info: ScheduleInfo) -> Scheduler { | ||
let reader = ConfigReader::default(); | ||
let database_factory = DataAccessFactory::new(reader.read_database_info().unwrap(), false) | ||
.await | ||
.unwrap(); | ||
let mealplan_management_data = database_factory.get_mealplan_management_data_access(); | ||
let parser = SwKaParseManager::new(reader.read_swka_info().unwrap()).unwrap(); | ||
|
||
let mealplan_management = MealPlanManager::new(mealplan_management_data, parser); | ||
Scheduler::new(info, ImageSchedulingMock::default(), mealplan_management).await | ||
} | ||
|
||
#[derive(Default)] | ||
struct ImageSchedulingMock {} | ||
|
||
#[async_trait] | ||
impl ImageReviewScheduling for ImageSchedulingMock { | ||
async fn start_image_review(&self) { | ||
return; | ||
} | ||
} |