Skip to content

Commit

Permalink
Test with impl Trait output
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos authored and la10736 committed Jun 28, 2020
1 parent 066e8f1 commit 0e411c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions resources/fixture/async_fixture.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::future::Future;
use std::io::prelude::*;

use rstest::*;

Expand All @@ -16,3 +17,13 @@ async fn default_is_async() {
async fn use_async_fixture(async_u32: impl Future<Output=u32>) {
assert_eq!(42, async_u32.await);
}

#[fixture]
async fn async_impl_output() -> impl Read {
std::io::Cursor::new(vec![1, 2, 3, 4, 5])
}

#[rstest]
async fn use_async_impl_output<T: Read>(async_impl_output: impl Future<Output = T>) {
let reader = async_impl_output.await;
}
1 change: 1 addition & 0 deletions tests/fixture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ mod should {
TestResults::new()
.ok("default_is_async")
.ok("use_async_fixture")
.ok("use_async_impl_output")
.assert(output);
}

Expand Down

0 comments on commit 0e411c3

Please sign in to comment.