aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-27 23:23:00 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-27 23:23:00 +0000
commitc30cbd35ba187cd6e5055d3beb8420b11fb030ec (patch)
tree60522f8d7c2230e7f04e3ec7f1f295d779a4a855 /tests
parentd433189caefe6bd6c88da7fbb1d6e9304353eb83 (diff)
downloadnitrokey-rs-c30cbd35ba187cd6e5055d3beb8420b11fb030ec.tar.gz
nitrokey-rs-c30cbd35ba187cd6e5055d3beb8420b11fb030ec.tar.bz2
Always return a Result when communicating with a device
Previously, we sometimes returned a value without wrapping it in a result if the API method did not indicate errors in the return value. But we can detect errors using the NK_get_last_command_status function. This patch changes the return types of these methods to Result<_, Error> and adds error checks.
Diffstat (limited to 'tests')
-rw-r--r--tests/device.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/device.rs b/tests/device.rs
index c790049..7ab4d66 100644
--- a/tests/device.rs
+++ b/tests/device.rs
@@ -95,9 +95,10 @@ fn get_serial_number(device: DeviceWrapper) {
}
#[test_device]
fn get_firmware_version(device: Pro) {
- assert_eq!(0, device.get_major_firmware_version());
+ assert_ok!(0, device.get_major_firmware_version());
let minor = device.get_minor_firmware_version();
- assert!(minor > 0);
+ assert!(minor.is_ok());
+ assert!(minor.unwrap() > 0);
}
fn admin_retry<T: Authenticate + Device>(device: T, suffix: &str, count: u8) -> T {
@@ -106,7 +107,7 @@ fn admin_retry<T: Authenticate + Device>(device: T, suffix: &str, count: u8) ->
Ok(admin) => admin.device(),
Err((device, _)) => device,
};
- assert_eq!(count, device.get_admin_retry_count());
+ assert_ok!(count, device.get_admin_retry_count());
return device;
}
@@ -116,7 +117,7 @@ fn user_retry<T: Authenticate + Device>(device: T, suffix: &str, count: u8) -> T
Ok(admin) => admin.device(),
Err((device, _)) => device,
};
- assert_eq!(count, device.get_user_retry_count());
+ assert_ok!(count, device.get_user_retry_count());
return device;
}