From 081fc2cbc85697cd6f1640526bb5e95f391de3bd Mon Sep 17 00:00:00 2001 From: daladim Date: Mon, 5 Apr 2021 23:26:20 +0200 Subject: [PATCH] [tests] Add a task that has various modifications --- tests/scenarii.rs | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/tests/scenarii.rs b/tests/scenarii.rs index 8352f4a..f0a5d2e 100644 --- a/tests/scenarii.rs +++ b/tests/scenarii.rs @@ -66,13 +66,13 @@ pub struct ItemScenario { } /// Generate the scenarii required for the following test: -/// * At the last sync: both sources had A, B, C, D, E, F, G, H, I, J, K, L, M✓, N✓, O✓ at last sync +/// * At the last sync: both sources had A, B, C, D, E, F, G, H, I, J, K, L, M✓, N✓, O✓, P✓ at last sync /// * Before the newer sync, this will be the content of the sources: -/// * cache: A, B, D', E, F'', G , H✓, I✓, J✓, M, N✓, O, P, -/// * server: A, C, D, E', F', G✓, H , I', K✓, M✓, N , O, Q +/// * cache: A, B, D', E, F'', G , H✓, I✓, J✓, M, N✓, O, P' , R +/// * server: A, C, D, E', F', G✓, H , I', K✓, M✓, N , O, P✓, Q /// /// Hence, here is the expected result after the sync: -/// * both: A, D', E', F', G✓, H✓, I', K✓, M, N, O, P, Q +/// * both: A, D', E', F', G✓, H✓, I', K✓, M, N, O, P', Q, R /// /// Notes: /// * X': name has been modified since the last sync @@ -343,14 +343,19 @@ pub fn scenarii_basic() -> Vec { tasks.push( ItemScenario { id: id_p.clone(), - initial_state: LocatedState::None, - local_changes_to_apply: vec![ChangeToApply::Create(main_cal.clone(), Item::Task( - Task::new(String::from("Task P, created locally"), id_p, SyncStatus::NotSynced, false ) - ))], + initial_state: LocatedState::BothSynced( ItemState{ + calendar: main_cal.clone(), + name: String::from("Task P"), + completed: true, + }), + local_changes_to_apply: vec![ + ChangeToApply::Rename(String::from("Task P, locally renamed and un-completed")), + ChangeToApply::SetCompletion(false), + ], remote_changes_to_apply: Vec::new(), after_sync: LocatedState::BothSynced( ItemState{ calendar: main_cal.clone(), - name: String::from("Task P, created locally"), + name: String::from("Task P, locally renamed and un-completed"), completed: false, }), } @@ -373,6 +378,23 @@ pub fn scenarii_basic() -> Vec { } ); + let id_r = ItemId::random(); + tasks.push( + ItemScenario { + id: id_r.clone(), + initial_state: LocatedState::None, + local_changes_to_apply: vec![ChangeToApply::Create(main_cal.clone(), Item::Task( + Task::new(String::from("Task R, created locally"), id_r, SyncStatus::NotSynced, false ) + ))], + remote_changes_to_apply: Vec::new(), + after_sync: LocatedState::BothSynced( ItemState{ + calendar: main_cal.clone(), + name: String::from("Task R, created locally"), + completed: false, + }), + } + ); + tasks }