Skip to content

Commit

Permalink
Merge pull request #475 from djmitche/issue455
Browse files Browse the repository at this point in the history
Test that pending tasks arriving via sync are in working set
  • Loading branch information
djmitche authored Oct 29, 2024
2 parents 2ebab88 + 6b45774 commit 3c88048
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion taskchampion/tests/cross-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,30 @@ fn cross_sync() -> anyhow::Result<()> {
let t1 = rep1.get_task(uuid1)?.expect("expected task 1 on rep1");
assert_eq!(t1.get_status(), Status::Completed);

let t22 = rep2.get_task(uuid2)?.expect("expected task 2 on rep2");
let mut t22 = rep2.get_task(uuid2)?.expect("expected task 2 on rep2");
assert_eq!(t22.get_status(), Status::Completed);

rep1.rebuild_working_set(true)?;
rep2.rebuild_working_set(true)?;

// Make task 2 pending again, and observe that it is in the working set in both replicas after
// sync.
let mut ops = Operations::new();
t22.set_status(Status::Pending, &mut ops)?;
rep2.commit_operations(ops)?;

let ws = rep2.working_set()?;
assert_eq!(ws.by_index(1), Some(uuid2));

// Pending status is not sync'd to rep1 yet.
let ws = rep1.working_set()?;
assert_eq!(ws.by_index(1), None);

rep2.sync(&mut server, false)?;
rep1.sync(&mut server, false)?;

let ws = rep1.working_set()?;
assert_eq!(ws.by_index(1), Some(uuid2));

Ok(())
}

0 comments on commit 3c88048

Please sign in to comment.