From 6dc06ab0731a103e32069ce00ed14c5240fe8e5c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 17 May 2021 19:23:10 +0100 Subject: [PATCH] apitest: Move bundles test to at-bundles Signed-off-by: Ian Jackson --- apitest/at-bundles.rs | 30 +++++++++++++++++++++++++++++- apitest/at-otter.rs | 29 ----------------------------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/apitest/at-bundles.rs b/apitest/at-bundles.rs index 3fd37786..cc7123da 100644 --- a/apitest/at-bundles.rs +++ b/apitest/at-bundles.rs @@ -7,10 +7,38 @@ use crate::*; type Ctx = UsualCtx; impl Ctx { + #[throws(Explode)] + fn bundles(&mut self) { + let bundle_file = self.su().ds.example_bundle(); + let ds = self.su().ds.also(&[("bundle", &bundle_file)]); + self.otter(&ds.ss("upload-bundle @table@ @bundle@")?)?; + let mut bundles = self.otter(&ds.ss("list-bundles @table@")?)?; + let bundles = String::from(&mut bundles); + assert!(bundles.starts_with("00000.zip Loaded")); + self.otter(&ds.ss("download-bundle @table@ 0")?)?; + let st = Command::new("cmp").args(&[&bundle_file, "00000.zip"]).status()?; + if ! st.success() { panic!("cmp failed {}", st) } + + let command = ds.ss("library-add --lib lemon @table@ example-lemon")?; + let added = self.some_library_add(&command)?; + assert_eq!( added.len(), 1 ); + + let output: String = self.otter(&ds.ss("list-pieces @table@")?)?.into(); + assert!( Regex::new( + r#"(?m)(?:[^\w-]|^)example-lemon[^\w-].*\Wa lemon(?:\W|$)"# + )? + .find(&output) + .is_some(), + "got: {}", &output); + + self.otter(&ds.ss("clear-game @table@")?)?; + self.otter(&ds.ss("reset @table@ demo")?)?; + } } #[throws(Explode)] -fn tests(_c: Ctx) { +fn tests(mut c: Ctx) { + test!(c, "bundles", c.bundles() ?); } #[throws(Explode)] diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index fd30821d..f776b805 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -190,34 +190,6 @@ impl Ctx { su.ds.setup_static_users(&mut *su.mgmt_conn.borrow_mut(), default())?; } - #[throws(Explode)] - fn bundles(&mut self) { - let bundle_file = self.su().ds.example_bundle(); - let ds = self.su().ds.also(&[("bundle", &bundle_file)]); - self.otter(&ds.ss("upload-bundle @table@ @bundle@")?)?; - let mut bundles = self.otter(&ds.ss("list-bundles @table@")?)?; - let bundles = String::from(&mut bundles); - assert!(bundles.starts_with("00000.zip Loaded")); - self.otter(&ds.ss("download-bundle @table@ 0")?)?; - let st = Command::new("cmp").args(&[&bundle_file, "00000.zip"]).status()?; - if ! st.success() { panic!("cmp failed {}", st) } - - let command = ds.ss("library-add --lib lemon @table@ example-lemon")?; - let added = self.some_library_add(&command)?; - assert_eq!( added.len(), 1 ); - - let output: String = self.otter(&ds.ss("list-pieces @table@")?)?.into(); - assert!( Regex::new( - r#"(?m)(?:[^\w-]|^)example-lemon[^\w-].*\Wa lemon(?:\W|$)"# - )? - .find(&output) - .is_some(), - "got: {}", &output); - - self.otter(&ds.ss("clear-game @table@")?)?; - self.otter(&ds.ss("reset @table@ demo")?)?; - } - #[throws(Explode)] fn save_load(&mut self) { { @@ -241,7 +213,6 @@ fn tests(mut c: Ctx) { test!(c, "hidden-hand", c.hidden_hand() ?); test!(c, "specs", c.chdir_root(|c| c.specs() )); test!(c, "put-back", c.put_back() ?); - test!(c, "bundles", c.bundles() ?); test!(c, "save-load", c.save_load() ?); } -- 2.30.2