Add test infrastructure to work directly with frames (#56)
This adds a `Codec` based testing API. This is a bit less annoying than writing at the raw H2 wire protocol level...
This commit is contained in:
32
tests/support/src/future_ext.rs
Normal file
32
tests/support/src/future_ext.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use futures::{Future, Poll};
|
||||
|
||||
use std::fmt;
|
||||
|
||||
pub trait FutureExt: Future {
|
||||
fn unwrap(self) -> Unwrap<Self>
|
||||
where Self: Sized,
|
||||
Self::Error: fmt::Debug,
|
||||
{
|
||||
Unwrap { inner: self }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Unwrap<T> {
|
||||
inner: T,
|
||||
}
|
||||
|
||||
impl<T: Future> FutureExt for T {
|
||||
}
|
||||
|
||||
impl<T> Future for Unwrap<T>
|
||||
where T: Future,
|
||||
T::Item: fmt::Debug,
|
||||
T::Error: fmt::Debug,
|
||||
{
|
||||
type Item = T::Item;
|
||||
type Error = ();
|
||||
|
||||
fn poll(&mut self) -> Poll<T::Item, ()> {
|
||||
Ok(self.inner.poll().unwrap())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user