From 3f0b04af6eba465c17ec4a9501a72df2171b2e64 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 5 Nov 2024 00:19:29 +0100 Subject: [PATCH] feat(test): added fixture macro --- src/tests/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 802c364..6349652 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -78,3 +78,23 @@ macro_rules! assert_or_err { } pub use assert_or_err; + +#[macro_export] +macro_rules! fixture { + ($fixture:expr => | $($arg:ident),* | $body:expr) => { + #[allow(unused_parens)] + $fixture + .with(|($($arg),*)| { + $( + let $arg = $arg.clone(); + )* + + async move { + $body + } + }) + .await; + }; +} + +pub use fixture;