chiark / gitweb /
tests: wip library-load
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 22 Feb 2021 00:50:33 +0000 (00:50 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 22 Feb 2021 00:50:33 +0000 (00:50 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Cargo.lock.example
apitest/Cargo.toml
apitest/at-otter.rs

index ac9f2656b00a2f15b2bee79cca010118cbc2e5af..d918faa03b06b475c323c8ef77533eec007ac66a 100644 (file)
@@ -1703,6 +1703,7 @@ dependencies = [
  "humantime",
  "num-traits",
  "otter",
+ "reqwest",
  "serde",
  "structopt",
  "strum",
index 91fe1f835edf53b62b4264426f9ca67ccf0f7c14..455496cd96bf7f38a3c11166a3246419a0bda35f 100644 (file)
@@ -14,6 +14,7 @@ edition = "2018"
 otter = { path = ".." }
 
 humantime = "2"
+reqwest = "0.11"
 
 # Repeated here because importing does not work properly
 fehler = "1"
index f8e229a243ee9a0f58be27d2d5b9e08edbd5a867..c7648ba515b545b73eefd88db3ca8aed8d81d795 100644 (file)
@@ -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<S:AsRef<str>>(&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");
 }