Skip to content

Commit

Permalink
Added implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
uglrl committed Aug 20, 2023
1 parent b1d51f2 commit 44e8ef3
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions backend/tests/mensa_parse_scheduling.rs
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;
}
}

0 comments on commit 44e8ef3

Please sign in to comment.