aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-27 19:14:51 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-07-09 08:43:11 +0000
commit0ac9c401c9968d39581fe2bc3a6610cb9a7a22d8 (patch)
treeef23544c5ec4cf5ffab2271edf7d65d17fd41864
parenta28b87a98a74687fb310e292b345ef540611fd21 (diff)
downloadnitrokey-rs-0ac9c401c9968d39581fe2bc3a6610cb9a7a22d8.tar.gz
nitrokey-rs-0ac9c401c9968d39581fe2bc3a6610cb9a7a22d8.tar.bz2
Use Manager in device connection tests
The previous patches refactored the connection handling to use the Manager struct. This patch changes the tests to use the new Manager methods instead of the deprecated functions.
-rw-r--r--tests/device.rs33
1 files changed, 15 insertions, 18 deletions
diff --git a/tests/device.rs b/tests/device.rs
index 76f38e6..bb71eb4 100644
--- a/tests/device.rs
+++ b/tests/device.rs
@@ -33,24 +33,19 @@ fn count_nitrokey_block_devices() -> usize {
#[test_device]
fn connect_no_device() {
- assert_cmu_err!(CommunicationError::NotConnected, nitrokey::connect());
- assert_cmu_err!(
- CommunicationError::NotConnected,
- nitrokey::take()
- .unwrap()
- .connect_model(nitrokey::Model::Pro)
- );
+ let mut manager = nitrokey::take().unwrap();
+
+ assert_cmu_err!(CommunicationError::NotConnected, manager.connect());
assert_cmu_err!(
CommunicationError::NotConnected,
- nitrokey::take()
- .unwrap()
- .connect_model(nitrokey::Model::Storage)
+ manager.connect_model(nitrokey::Model::Pro)
);
- assert_cmu_err!(CommunicationError::NotConnected, nitrokey::Pro::connect());
assert_cmu_err!(
CommunicationError::NotConnected,
- nitrokey::Storage::connect()
+ manager.connect_model(nitrokey::Model::Storage)
);
+ assert_cmu_err!(CommunicationError::NotConnected, manager.connect_pro());
+ assert_cmu_err!(CommunicationError::NotConnected, manager.connect_storage());
}
#[test_device]
@@ -58,9 +53,10 @@ fn connect_pro(device: Pro) {
assert_eq!(device.get_model(), nitrokey::Model::Pro);
drop(device);
- assert_any_ok!(nitrokey::connect());
- assert_any_ok!(nitrokey::take().unwrap().connect_model(nitrokey::Model::Pro));
- assert_any_ok!(nitrokey::take().unwrap().connect_pro());
+ let mut manager = nitrokey::take().unwrap();
+ assert_any_ok!(manager.connect());
+ assert_any_ok!(manager.connect_model(nitrokey::Model::Pro));
+ assert_any_ok!(manager.connect_pro());
}
#[test_device]
@@ -68,9 +64,10 @@ fn connect_storage(device: Storage) {
assert_eq!(device.get_model(), nitrokey::Model::Storage);
drop(device);
- assert_any_ok!(nitrokey::connect());
- assert_any_ok!(nitrokey::take().unwrap().connect_model(nitrokey::Model::Storage));
- assert_any_ok!(nitrokey::take().unwrap().connect_storage());
+ let mut manager = nitrokey::take().unwrap();
+ assert_any_ok!(manager.connect());
+ assert_any_ok!(manager.connect_model(nitrokey::Model::Storage));
+ assert_any_ok!(manager.connect_storage());
}
fn assert_empty_serial_number() {