From 84fa7ccb105adecdff52c394cd5bcc1e28d965e9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 22 Feb 2021 00:50:33 +0000 Subject: [PATCH] tests: wip library-load Signed-off-by: Ian Jackson --- Cargo.lock.example | 1 + apitest/Cargo.toml | 1 + apitest/at-otter.rs | 26 ++++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Cargo.lock.example b/Cargo.lock.example index ac9f2656..d918faa0 100644 --- a/Cargo.lock.example +++ b/Cargo.lock.example @@ -1703,6 +1703,7 @@ dependencies = [ "humantime", "num-traits", "otter", + "reqwest", "serde", "structopt", "strum", diff --git a/apitest/Cargo.toml b/apitest/Cargo.toml index 91fe1f83..455496cd 100644 --- a/apitest/Cargo.toml +++ b/apitest/Cargo.toml @@ -14,6 +14,7 @@ edition = "2018" otter = { path = ".." } humantime = "2" +reqwest = "0.11" # Repeated here because importing does not work properly fehler = "1" diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index f8e229a2..c7648ba5 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -11,9 +11,24 @@ struct Ctx { opts: Opts, su: SetupCore, spec: GameSpec, + alice: Player, + bob: Player, } deref_to_field!{Ctx, SetupCore, su} +#[derive(Debug)] +struct Player { + url: String, +} + +impl Player { + #[throws(AE)] + fn connect(&self) { + let body = reqwest::blocking::get(&self.url)?; + dbg!(&body); + } +} + impl Ctx { #[throws(AE)] pub fn otter>(&mut self, args: &[S]) { @@ -29,6 +44,8 @@ impl Ctx { prepare_game(&self.ds, TABLE)?; self.otter(&self.ds.ss("library-add @table@ wikimedia chess-blue-?")?)?; + + self.alice.connect()?; } } @@ -42,8 +59,13 @@ fn main() { { let (opts, _cln, instance, mut su) = setup_core(&[module_path!()])?; let spec = su.ds.game_spec_data()?; - let users = su.ds.setup_static_users(default(), |_|Ok(()))?; - tests(Ctx { opts, spec, su })?; + let [alice, bob]: [Player; 2] = su.ds.setup_static_users( + default(), + |sus| Ok(Player { url: sus.url }) + )? + .try_into().unwrap(); + + tests(Ctx { opts, spec, su, alice, bob })?; } info!("ok"); } -- 2.30.2