diff --git a/tests/routes.rs b/tests/routes.rs index 9e38fe2f..0b4d8098 100644 --- a/tests/routes.rs +++ b/tests/routes.rs @@ -4,6 +4,7 @@ use std::sync::{ }; use bytes::BytesMut; +use rstest::rstest; use wireframe::{ Serializer, app::WireframeApp, @@ -24,6 +25,7 @@ struct TestEnvelope { #[derive(bincode::Encode, bincode::BorrowDecode, PartialEq, Debug)] struct Echo(u8); +#[rstest] #[tokio::test] async fn handler_receives_message_and_echoes_response() { let called = Arc::new(AtomicUsize::new(0)); diff --git a/tests/util.rs b/tests/util.rs index 16371c41..cd136a84 100644 --- a/tests/util.rs +++ b/tests/util.rs @@ -1,5 +1,6 @@ +use rstest::fixture; use tokio::io::{self, AsyncReadExt, AsyncWriteExt, duplex}; -use wireframe::app::WireframeApp; +use wireframe::{app::WireframeApp, frame::LengthPrefixedProcessor}; /// Feed a single frame into `app` and collect the response bytes. /// @@ -13,6 +14,13 @@ use wireframe::app::WireframeApp; /// Optional duplex buffer capacity for `run_app_with_frame`. const DEFAULT_CAPACITY: usize = 4096; +/// Create a default length-prefixed frame processor for tests. +#[fixture] +#[rustfmt::skip] +pub fn processor() -> LengthPrefixedProcessor { + LengthPrefixedProcessor::default() +} + /// Run `app` with a single input `frame` using the default buffer capacity. /// /// # Errors