#async #mock #stream #futures

futures-mockstream

Minimal mockstream which implements futures async traits

3 releases

0.1.2 May 6, 2020
0.1.1 May 6, 2020
0.1.0 May 6, 2020

#334 in Asynchronous

MIT/Apache

8KB
138 lines

Futures MockStream

MockStream for futures crate Async{Read, Write} and Stream traits

Install

Install from crates.io

[dependencies]
futures-mockstream = "0.1"

Example

with smol

use futures-mockStream::MockStream;
use smol;


#[cfg(test)]
mod tests {
    #[test]
    fn async_read() {
        smol::run(async {
            let mut mockstream = MockStream::from(&b"GET /index HTTP/1.1\r\n");
            while let Some(resp) = MyConn::with_stream(mockstream).next().await {
                match resp {
                    Ok(r) => { // your asserts },
                    Err(e) => {},
                }
            }
        })
    }
}

Dependencies

~71KB