keyforkd: complicate middleware test

This commit is contained in:
Ryan Heywood 2023-09-07 15:35:34 -05:00
parent b810ab2e90
commit 8510e382d2
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 13 additions and 4 deletions

View File

@ -100,6 +100,14 @@ mod tests {
field: String, field: String,
} }
impl Test {
fn new() -> Self {
Self {
field: "hello world!".to_string()
}
}
}
struct App; struct App;
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
@ -118,15 +126,16 @@ mod tests {
} }
fn call(&mut self, req: Test) -> Self::Future { fn call(&mut self, req: Test) -> Self::Future {
Box::pin(async { Ok(req) }) Box::pin(async {
assert_eq!(req.field, Test::new().field);
Ok(req)
})
} }
} }
#[tokio::test] #[tokio::test]
async fn can_serde_responses() { async fn can_serde_responses() {
let content = serialize(&Test { let content = serialize(&Test::new())
field: "hello world!".to_string(),
})
.unwrap(); .unwrap();
let mut service = ServiceBuilder::new() let mut service = ServiceBuilder::new()
.layer(BincodeLayer::<Test>::new()) .layer(BincodeLayer::<Test>::new())