From 54f77851093932d82076f9ef393753e9d6692179 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Fri, 4 Jan 2019 13:00:23 -0800 Subject: 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!(().is_ok()) to compare against Ok(()) instead. This way, if the result is not the Ok variant, the error code will get printed. --- tests/device.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/device.rs') 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()); } -- cgit v1.2.1