use std::fmt::Debug; use tonic::Streaming; pub(crate) async fn assert_stream_eq(mut stream: Streaming, expected: X) where S: PartialEq, X: IntoIterator + Send, { let mut expected = expected.into_iter(); while let Ok(Some(stream_item)) = stream.message().await { match (stream_item, expected.next()) { (stream_item, Some(expected_item)) => { assert!(stream_item == expected_item); } (_, None) => panic!("stream has more items than expected"), } } assert!(expected.next().is_none()); }