Skip to content

Commit 70f5ae4

Browse files
committed
test(common): add basic test for AlertOnEos
1 parent d61db23 commit 70f5ae4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/common/buf.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,16 @@ impl<B: Buf> Buf for AlertOnEos<B> {
6161

6262
#[cfg(test)]
6363
mod tests {
64+
use std::time::Duration;
65+
use hyper::body::{Buf, Bytes};
66+
use crate::common::buf::AlertOnEos;
6467

68+
#[tokio::test]
69+
async fn test_get_notified() {
70+
let buf = Bytes::from_static(b"abc");
71+
let (mut buf, signaler) = AlertOnEos::new(buf);
72+
buf.advance(3);
73+
let result = tokio::time::timeout(Duration::from_secs(1), signaler.wait_till_eos()).await;
74+
assert_eq!(result, Ok(()));
75+
}
6576
}

0 commit comments

Comments
 (0)