Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[cfg(test)]
- mod tests {
- use super::*;
- use std::fs;
- use tempdir::TempDir;
- #[tokio::test]
- async fn test_mailbox_senders() -> Result<(), Box<dyn std::error::Error>> {
- let tmp_dir = TempDir::new("test_mailbox")?;
- let address = tmp_dir.path().join("test_message_1");
- let mut mailbox_sender = MailboxSenders::default();
- let (tx, fut) = mailbox_sender.create(address.clone());
- tx.unbounded_send("foo\n".into())?;
- mailbox_sender
- .get(&address)
- .unwrap()
- .unbounded_send("bar".into())?;
- tx.unbounded_send("baz\n".into())?;
- mailbox_sender.remove(&address);
- drop(tx);
- fut.await?;
- let contents = fs::read_to_string(&address).unwrap();
- assert_eq!(contents, "foo\nbar\nbaz\n");
- Ok(())
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement