diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-07-09 11:03:01 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-07-09 13:07:52 +0200 |
commit | a0ebd37765027121b85dfd6b78b453a50adc69c9 (patch) | |
tree | 4f2a8b943382660e2a5c8f4c2eb578fe4477d060 /tests | |
parent | 4dc5b7e73ef348f18b4d2b032dc9a27059f4c47f (diff) | |
download | nitrokey-rs-a0ebd37765027121b85dfd6b78b453a50adc69c9.tar.gz nitrokey-rs-a0ebd37765027121b85dfd6b78b453a50adc69c9.tar.bz2 |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/device.rs | 8 |
1 files 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()); |