From d5b6d57f23cb0eb52508060aef24183a21428b08 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 17 May 2021 18:19:55 +0100 Subject: [PATCH] apitest: Move setup code to apitest/main Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 14 +------------- apitest/main.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index fb1843d4..fd30821d 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -247,17 +247,5 @@ fn tests(mut c: Ctx) { #[throws(Explode)] pub fn main() { - let (opts, _instance, su) = setup_core( - &[module_path!()], - )?; - let spec = su.ds.game_spec_data()?; - let mut mc = su.mgmt_conn(); - let [alice, bob]: [Player; 2] = - su.ds.setup_static_users(&mut mc, default())? - .into_iter().map(|sus| Player { nick: sus.nick, url: sus.url }) - .collect::>().into_inner().unwrap(); - drop(mc); - - let su_rc = Rc::new(RefCell::new(su)); - tests(Ctx { opts, spec, su_rc, alice, bob, prctx: default() })?; + tests(UsualCtx::setup()?)?; } diff --git a/apitest/main.rs b/apitest/main.rs index 98afbb66..4657999e 100644 --- a/apitest/main.rs +++ b/apitest/main.rs @@ -540,6 +540,25 @@ impl UsualCtx { } } +impl UsualCtx { + #[throws(AE)] + pub fn setup() -> Self { + let (opts, _instance, su) = setup_core( + &[module_path!()], + )?; + let spec = su.ds.game_spec_data()?; + let mut mc = su.mgmt_conn(); + let [alice, bob]: [Player; 2] = + su.ds.setup_static_users(&mut mc, default())? + .into_iter().map(|sus| Player { nick: sus.nick, url: sus.url }) + .collect::>().into_inner().unwrap(); + drop(mc); + + let su_rc = Rc::new(RefCell::new(su)); + UsualCtx { opts, spec, su_rc, alice, bob, prctx: default() } + } +} + portmanteau_has!("at-otter.rs", at_otter); portmanteau_has!("at-bundles.rs", at_bundles); -- 2.30.2