From 0ec027eb0b8a512addec8cd599593bb7fbba8b10 Mon Sep 17 00:00:00 2001 From: Tomek Karwowski Date: Fri, 19 Aug 2022 21:42:08 +0200 Subject: [PATCH] test(common): add basic test for AlertOnEos --- src/common/buf.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/common/buf.rs b/src/common/buf.rs index 3b42682..455085b 100644 --- a/src/common/buf.rs +++ b/src/common/buf.rs @@ -61,5 +61,16 @@ impl Buf for AlertOnEos { #[cfg(test)] mod tests { + use crate::common::buf::AlertOnEos; + use hyper::body::{Buf, Bytes}; + use std::time::Duration; -} \ No newline at end of file + #[tokio::test] + async fn test_get_notified() { + let buf = Bytes::from_static(b"abc"); + let (mut buf, signaler) = AlertOnEos::new(buf); + buf.advance(3); + let result = tokio::time::timeout(Duration::from_secs(1), signaler.wait_till_eos()).await; + assert_eq!(result, Ok(())); + } +}