Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit d68767f

Browse files
committed
Add test for checking if MainContext Senders return errors when the Receiver is removed from the context
1 parent 65482e3 commit d68767f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main_context_channel.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,4 +449,20 @@ mod tests {
449449
drop(receiver);
450450
assert_eq!(sender.send(1), Err(mpsc::SendError(1)));
451451
}
452+
453+
#[test]
454+
fn test_remove_receiver() {
455+
let c = MainContext::new();
456+
457+
c.acquire();
458+
459+
let (sender, receiver) = MainContext::channel::<i32>(Priority::default());
460+
461+
let source_id = receiver.attach(&c, move |_| Continue(true));
462+
463+
let source = c.find_source_by_id(&source_id).unwrap();
464+
source.destroy();
465+
466+
assert_eq!(sender.send(1), Err(mpsc::SendError(1)));
467+
}
452468
}

0 commit comments

Comments
 (0)