-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from asomers/async_trait
async_trait compatibility
- Loading branch information
Showing
12 changed files
with
191 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// vim: tw=80 | ||
//! An async trait, for use with Futures | ||
#![deny(warnings)] | ||
|
||
use async_trait::async_trait; | ||
use futures::executor::block_on; | ||
use mockall::*; | ||
|
||
#[automock] | ||
#[async_trait] | ||
pub trait Foo { | ||
async fn foo(&self) -> u32; | ||
} | ||
|
||
|
||
#[test] | ||
fn return_const() { | ||
let mut mock = MockFoo::new(); | ||
mock.expect_foo() | ||
.return_const(42u32); | ||
assert_eq!(block_on(mock.foo()), 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// vim: tw=80 | ||
//! A struct with an async function | ||
#![deny(warnings)] | ||
|
||
use futures::executor::block_on; | ||
use mockall::*; | ||
|
||
mock! { | ||
pub Foo { | ||
async fn foo(&self) -> u32; | ||
} | ||
} | ||
|
||
#[test] | ||
fn return_const() { | ||
let mut mock = MockFoo::new(); | ||
mock.expect_foo() | ||
.return_const(42u32); | ||
assert_eq!(block_on(mock.foo()), 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// vim: tw=80 | ||
//! An async trait, for use with Futures | ||
#![deny(warnings)] | ||
|
||
use async_trait::async_trait; | ||
use futures::executor::block_on; | ||
use mockall::*; | ||
|
||
#[async_trait] | ||
pub trait Foo { | ||
async fn foo(&self) -> u32; | ||
} | ||
|
||
mock! { | ||
pub Bar { } | ||
#[async_trait] | ||
trait Foo { | ||
async fn foo(&self) -> u32; | ||
} | ||
} | ||
|
||
#[test] | ||
fn return_const() { | ||
let mut mock = MockBar::new(); | ||
mock.expect_foo() | ||
.return_const(42u32); | ||
assert_eq!(block_on(mock.foo()), 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.