From a0ebd37765027121b85dfd6b78b453a50adc69c9 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 9 Jul 2019 11:03:01 +0000 Subject: Use into_manager in device connection tests To avoid a ConcurrentAccessError, we have to use the Device::into_manager function instead of calling take to obtain a Manager instance. --- tests/device.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/device.rs b/tests/device.rs index bb71eb4..a2bdfb5 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -33,7 +33,7 @@ fn count_nitrokey_block_devices() -> usize { #[test_device] fn connect_no_device() { - let mut manager = nitrokey::take().unwrap(); + let mut manager = unwrap_ok!(nitrokey::take()); assert_cmu_err!(CommunicationError::NotConnected, manager.connect()); assert_cmu_err!( @@ -51,9 +51,8 @@ fn connect_no_device() { #[test_device] fn connect_pro(device: Pro) { assert_eq!(device.get_model(), nitrokey::Model::Pro); - drop(device); - let mut manager = nitrokey::take().unwrap(); + let manager = device.into_manager(); assert_any_ok!(manager.connect()); assert_any_ok!(manager.connect_model(nitrokey::Model::Pro)); assert_any_ok!(manager.connect_pro()); @@ -62,9 +61,8 @@ fn connect_pro(device: Pro) { #[test_device] fn connect_storage(device: Storage) { assert_eq!(device.get_model(), nitrokey::Model::Storage); - drop(device); - let mut manager = nitrokey::take().unwrap(); + let manager = device.into_manager(); assert_any_ok!(manager.connect()); assert_any_ok!(manager.connect_model(nitrokey::Model::Storage)); assert_any_ok!(manager.connect_storage()); -- cgit v1.2.3