chiark / gitweb /
bundles: Test finding specs in bundles
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 20 May 2021 00:31:24 +0000 (01:31 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 20 May 2021 00:41:54 +0000 (01:41 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-bundles.rs
apitest/main.rs

index ad2f9c1fb91dc6d110848da38860c716b9747bcd..05dbbffd6f7c60126309751c2089f3d2587e8b36 100644 (file)
@@ -10,15 +10,24 @@ impl Ctx {
   #[throws(Explode)]
   fn bundles(&mut self) {
     self.upload_and_check_bundle(
-      "test-bundle","lemon", "example-lemon","a lemon"
-    )?;
+      "test-bundle","lemon", "example-lemon","a lemon",
+      &mut |_|Ok(()))?;
   }
  
   #[throws(Explode)]
   fn big(&mut self) {
     self.upload_and_check_bundle(
-      "big-bundle","duped-example", "chess-purple-cannon", "a purple cannon"
-    )?;
+      "big-bundle","duped-example", "chess-purple-cannon", "a purple cannon",
+      &mut |ctx|
+    {
+      ctx.su().mgmt_conn.borrow_mut().alter_game(
+        vec![ MGI::ResetFromNamedSpec {
+          spec: "modded-spec".to_owned(),
+        }],
+        None,
+      )?;
+      Ok(())
+    })?;
   }
  
   #[throws(Explode)]
index 9336a0d0e91e438d5a685c7f6aa83e2f0870642a..2f6a6cccd1718d6ad4058a3c27c9549ada917aa3 100644 (file)
@@ -587,10 +587,12 @@ impl UsualCtx {
   }
 
   #[throws(Explode)]
-  pub fn upload_and_check_bundle(&mut self, bundle_stem: &str,
-                                 libname: &str, item: &str,
-                                 desc: &str)
-  {
+  pub fn upload_and_check_bundle(
+    &mut self, bundle_stem: &str,
+    libname: &str, item: &str,
+    desc: &str,
+    with: &mut dyn FnMut(&mut UsualCtx) -> Result<(), Explode>
+  ) {
     let ds = self.su().ds.also(&[("bundle_stem", &bundle_stem)]);
     let bundle_file = ds.subst("@examples@/@bundle_stem@.zip")?;
     let ds = ds.also(&[("bundle", &bundle_file)]);
@@ -616,6 +618,8 @@ impl UsualCtx {
 
     self.check_library_item(libname,item,desc)?;
 
+    with(self)?;
+
     self.otter(&ds.ss("clear-game @table@")?)?;
     self.reset_game(&ds.ss("reset @table@ demo")?)?;
   }