[tests] Testing a first sync from a server

This commit is contained in:
daladim 2021-04-03 19:38:18 +02:00
parent 88af366edf
commit 427212be89
2 changed files with 135 additions and 22 deletions

View file

@ -78,7 +78,7 @@ pub struct ItemScenario {
/// * X': name has been modified since the last sync
/// * X'/X'': name conflict
/// * X✓: task has been marked as completed
pub fn basic_scenarii() -> Vec<ItemScenario> {
pub fn scenarii_basic() -> Vec<ItemScenario> {
let mut tasks = Vec::new();
let main_cal = CalendarId::from("https://some.calend.ar/main/".parse().unwrap());
@ -376,6 +376,70 @@ pub fn basic_scenarii() -> Vec<ItemScenario> {
tasks
}
/// This scenario basically checks a first sync to an empty local cache
pub fn scenarii_first_sync_to_local() -> Vec<ItemScenario> {
let mut tasks = Vec::new();
let cal1 = CalendarId::from("https://some.calend.ar/first/".parse().unwrap());
let cal2 = CalendarId::from("https://some.calend.ar/second/".parse().unwrap());
tasks.push(
ItemScenario {
id: ItemId::random(),
initial_state: LocatedState::Remote( ItemState{
calendar: cal1.clone(),
name: String::from("Task A1"),
completed: false,
}),
local_changes_to_apply: Vec::new(),
remote_changes_to_apply: Vec::new(),
after_sync: LocatedState::BothSynced( ItemState{
calendar: cal1.clone(),
name: String::from("Task A1"),
completed: false,
}),
}
);
tasks.push(
ItemScenario {
id: ItemId::random(),
initial_state: LocatedState::Remote( ItemState{
calendar: cal2.clone(),
name: String::from("Task A2"),
completed: false,
}),
local_changes_to_apply: Vec::new(),
remote_changes_to_apply: Vec::new(),
after_sync: LocatedState::BothSynced( ItemState{
calendar: cal2.clone(),
name: String::from("Task A2"),
completed: false,
}),
}
);
tasks.push(
ItemScenario {
id: ItemId::random(),
initial_state: LocatedState::Remote( ItemState{
calendar: cal1.clone(),
name: String::from("Task B1"),
completed: false,
}),
local_changes_to_apply: Vec::new(),
remote_changes_to_apply: Vec::new(),
after_sync: LocatedState::BothSynced( ItemState{
calendar: cal1.clone(),
name: String::from("Task B1"),
completed: false,
}),
}
);
tasks
}
/// Build a `Provider` that contains the data (defined in the given scenarii) before sync
pub async fn populate_test_provider_before_sync(scenarii: &[ItemScenario]) -> Provider<Cache, CachedCalendar, Cache, CachedCalendar> {
let mut provider = populate_test_provider(scenarii, false).await;