Skip to content

Commit

Permalink
Add watch::Rceiver::has_changed to the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elichai committed Dec 24, 2021
1 parent 1a380a4 commit ef46573
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tokio/tests/sync_watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,24 @@ fn poll_close() {
fn borrow_and_update() {
let (tx, mut rx) = watch::channel("one");

assert!(!rx.has_changed().unwrap());

tx.send("two").unwrap();
assert!(rx.has_changed().unwrap());
assert_ready!(spawn(rx.changed()).poll()).unwrap();
assert_pending!(spawn(rx.changed()).poll());
assert!(!rx.has_changed().unwrap());

tx.send("three").unwrap();
assert!(rx.has_changed().unwrap());
assert_eq!(*rx.borrow_and_update(), "three");
assert_pending!(spawn(rx.changed()).poll());
assert!(!rx.has_changed().unwrap());

drop(tx);
assert_eq!(*rx.borrow_and_update(), "three");
assert_ready!(spawn(rx.changed()).poll()).unwrap_err();
assert!(rx.has_changed().is_err());
}

#[test]
Expand Down

0 comments on commit ef46573

Please sign in to comment.