From ea28b348548b0052e5d289dc61874c1b80f95b69 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 15 May 2021 19:30:12 +0100 Subject: [PATCH] apitest: Break out some_library_add Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index da8eced8..df1b40ad 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -512,22 +512,8 @@ impl Ctx { } #[throws(Explode)] - fn library_load(&mut self) { - prepare_game(&self.su().ds, &self.prctx, TABLE)?; - - let command = self.su().ds.ss( - "library-list @table@ wikimedia chess-yellow-?" - )?; - let output: String = self.otter(&command)?.into(); - assert!( Regex::new("(?m)^chess-yellow-K *the yellow king$")? - .find(&output) - .is_some(), - "got: {}", &output); - - let command = self.su().ds.ss( - "library-add @table@ wikimedia chess-blue-?" - )?; - let add_err = self.otter(&command) + fn some_library_add(&mut self, command: &[String]) -> Vec { + let add_err = self.otter(command) .expect_err("library-add succeeded after reset!"); assert_eq!(add_err.downcast::()?.0.code(), Some(EXIT_NOTFOUND)); @@ -547,7 +533,28 @@ impl Ctx { then { added.push(piece); } } )?; + dbgc!(&added); + added + } + + #[throws(Explode)] + fn library_load(&mut self) { + prepare_game(&self.su().ds, &self.prctx, TABLE)?; + + let command = self.su().ds.ss( + "library-list @table@ wikimedia chess-yellow-?" + )?; + let output: String = self.otter(&command)?.into(); + assert!( Regex::new("(?m)^chess-yellow-K *the yellow king$")? + .find(&output) + .is_some(), + "got: {}", &output); + + let command = self.su().ds.ss( + "library-add @table@ wikimedia chess-blue-?" + )?; + let added = self.some_library_add(&command)?; assert_eq!(added.len(), 6); } -- 2.30.2