From 2dbc3748f9eec4a4fc9163e979b1d9d8efb3e2a0 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sat, 5 Sep 2020 06:14:38 -0700 Subject: Remove Nitrocli::model method While the Nitrocli::model() method was well intentioned, we do not actually need it because we create a Nitrocli instance from the model passed to the individual test. We can just reuse this model instead. With this patch we do exactly that, allowing us to get rid of Nitrocli::model() all together. --- src/tests/mod.rs | 4 ---- src/tests/pin.rs | 2 +- src/tests/reset.rs | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src/tests') diff --git a/src/tests/mod.rs b/src/tests/mod.rs index e1f93a9..d31348b 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -120,8 +120,4 @@ impl Nitrocli { let (res, out, _) = self.do_run(args, |c, a| crate::handle_arguments(c, a)); res.map(|_| String::from_utf8_lossy(&out).into_owned()) } - - pub fn model(&self) -> Option { - self.model - } } diff --git a/src/tests/pin.rs b/src/tests/pin.rs index 551454c..7770fba 100644 --- a/src/tests/pin.rs +++ b/src/tests/pin.rs @@ -61,7 +61,7 @@ fn set_user(model: nitrokey::Model) -> anyhow::Result<()> { { let mut manager = nitrokey::force_take()?; - let device = manager.connect_model(ncli.model().unwrap())?; + let device = manager.connect_model(model)?; let _ = device .authenticate_user(nitrokey::DEFAULT_USER_PIN) .unwrap(); diff --git a/src/tests/reset.rs b/src/tests/reset.rs index a7b2097..bf1e75b 100644 --- a/src/tests/reset.rs +++ b/src/tests/reset.rs @@ -20,7 +20,7 @@ fn reset(model: nitrokey::Model) -> anyhow::Result<()> { { let mut manager = nitrokey::force_take()?; // Check that the admin PIN has been changed. - let device = manager.connect_model(ncli.model().unwrap())?; + let device = manager.connect_model(model)?; let _ = device.authenticate_admin(new_admin_pin).unwrap(); } @@ -32,7 +32,7 @@ fn reset(model: nitrokey::Model) -> anyhow::Result<()> { { let mut manager = nitrokey::force_take()?; // Check that the admin PIN has been reset. - let device = manager.connect_model(ncli.model().unwrap())?; + let device = manager.connect_model(model)?; let mut device = device .authenticate_admin(nitrokey::DEFAULT_ADMIN_PIN) .unwrap(); -- cgit v1.2.3