aboutsummaryrefslogtreecommitdiff
path: root/tests/device.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-01-04 13:00:23 -0800
committerRobin Krahl <robin.krahl@ireas.org>2019-01-05 10:28:49 +0100
commit54f77851093932d82076f9ef393753e9d6692179 (patch)
treeae88b22646e22a2c86d0a8ed5fa53855f0f8fa65 /tests/device.rs
parent7645f3964cf8060181b8fac130686e09959f00e1 (diff)
downloadnitrokey-rs-54f77851093932d82076f9ef393753e9d6692179.tar.gz
nitrokey-rs-54f77851093932d82076f9ef393753e9d6692179.tar.bz2
Prefer assert_eq over is_ok() checks
We experienced various problems running the tests and while they may or may not be caused by local setup issues, it is helpful to have more information than just an indication that an assertion (true/false) was violated. To that end, this change adjusts some of the assert!(<func>().is_ok()) to compare against Ok(()) instead. This way, if the result is not the Ok variant, the error code will get printed.
Diffstat (limited to 'tests/device.rs')
-rw-r--r--tests/device.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/device.rs b/tests/device.rs
index 0c8bb26..d6ed0c4 100644
--- a/tests/device.rs
+++ b/tests/device.rs
@@ -120,7 +120,7 @@ fn get_retry_count(device: DeviceWrapper) {
fn config(device: DeviceWrapper) {
let admin = device.authenticate_admin(ADMIN_PASSWORD).unwrap();
let config = Config::new(None, None, None, true);
- assert!(admin.write_config(config).is_ok());
+ assert_eq!(Ok(()), admin.write_config(config));
let get_config = admin.get_config().unwrap();
assert_eq!(config, get_config);
@@ -128,12 +128,12 @@ fn config(device: DeviceWrapper) {
assert_eq!(Err(CommandError::InvalidSlot), admin.write_config(config));
let config = Config::new(Some(1), None, Some(0), false);
- assert!(admin.write_config(config).is_ok());
+ assert_eq!(Ok(()), admin.write_config(config));
let get_config = admin.get_config().unwrap();
assert_eq!(config, get_config);
let config = Config::new(None, None, None, false);
- assert!(admin.write_config(config).is_ok());
+ assert_eq!(Ok(()), admin.write_config(config));
let get_config = admin.get_config().unwrap();
assert_eq!(config, get_config);
}
@@ -332,26 +332,26 @@ fn change_update_pin(device: Storage) {
#[test_device]
fn encrypted_volume(device: Storage) {
- assert!(device.lock().is_ok());
+ assert_eq!(Ok(()), device.lock());
assert_eq!(1, count_nitrokey_block_devices());
- assert!(device.disable_encrypted_volume().is_ok());
+ assert_eq!(Ok(()), device.disable_encrypted_volume());
assert_eq!(1, count_nitrokey_block_devices());
assert_eq!(
Err(CommandError::WrongPassword),
device.enable_encrypted_volume("123")
);
assert_eq!(1, count_nitrokey_block_devices());
- assert!(device.enable_encrypted_volume(USER_PASSWORD).is_ok());
+ assert_eq!(Ok(()), device.enable_encrypted_volume(USER_PASSWORD));
assert_eq!(2, count_nitrokey_block_devices());
- assert!(device.disable_encrypted_volume().is_ok());
+ assert_eq!(Ok(()), device.disable_encrypted_volume());
assert_eq!(1, count_nitrokey_block_devices());
}
#[test_device]
fn lock(device: Storage) {
- assert!(device.enable_encrypted_volume(USER_PASSWORD).is_ok());
- assert!(device.lock().is_ok());
+ assert_eq!(Ok(()), device.enable_encrypted_volume(USER_PASSWORD));
+ assert_eq!(Ok(()), device.lock());
assert_eq!(1, count_nitrokey_block_devices());
}