Provider uses update_item

This commit is contained in:
daladim 2021-04-18 00:32:13 +02:00
parent 266437a4d1
commit 8fd416fae1
2 changed files with 20 additions and 22 deletions

View file

@ -314,17 +314,8 @@ where
continue;
},
Some(item) => {
//
//
//
//
// TODO: implement update_item (maybe only create_item also updates it?)
//
if let Err(err) = cal_local.immediately_delete_item(&id_change).await {
result.error(&format!("Unable to delete (update) item {} from local calendar: {}", id_change, err));
}
if let Err(err) = cal_local.add_item(item.clone()).await {
result.error(&format!("Unable to add (update) item {} to local calendar: {}", id_change, err));
if let Err(err) = cal_local.update_item(item.clone()).await {
result.error(&format!("Unable to update item {} in local calendar: {}", id_change, err));
}
},
}
@ -359,17 +350,8 @@ where
continue;
},
Some(item) => {
//
//
//
//
// TODO: implement update_item (maybe only create_item also updates it?)
//
if let Err(err) = cal_remote.delete_item(&id_change).await {
result.error(&format!("Unable to delete (update) item {} from remote calendar: {}", id_change, err));
}
match cal_remote.add_item(item.clone()).await {
Err(err) => log::error!("Unable to add (update) item {} to remote calendar: {}", id_change, err),
match cal_remote.update_item(item.clone()).await {
Err(err) => result.error(&format!("Unable to update item {} in remote calendar: {}", id_change, err)),
Ok(new_ss) => {
// Update local sync status
item.set_sync_status(new_ss);

View file

@ -34,6 +34,7 @@ impl TestFlavour {
pub fn normal_with_errors9() -> Self { Self{} }
pub fn normal_with_errors10() -> Self { Self{} }
pub fn normal_with_errors11() -> Self { Self{} }
pub fn normal_with_errors12() -> Self { Self{} }
pub async fn run(&self, _max_attempts: u32) {
println!("WARNING: This test required the \"integration_tests\" Cargo feature");
@ -188,6 +189,16 @@ impl TestFlavour {
}
}
pub fn normal_with_errors12() -> Self {
Self {
scenarii: scenarii::scenarii_basic(),
mock_behaviour: Arc::new(Mutex::new(MockBehaviour{
update_item_behaviour: (0,3),
..MockBehaviour::default()
})),
}
}
pub async fn run(&self, max_attempts: u32) {
self.mock_behaviour.lock().unwrap().suspend();
@ -306,6 +317,11 @@ async fn test_errors_in_regular_sync11() {
run_flavour(TestFlavour::normal_with_errors11(), 100).await;
}
#[tokio::test]
async fn test_errors_in_regular_sync12() {
run_flavour(TestFlavour::normal_with_errors12(), 100).await;
}
#[cfg(feature = "integration_tests")]
use my_tasks::{traits::CalDavSource,
Provider,