summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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() {