diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/device.rs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/tests/device.rs b/tests/device.rs index 1669d9d..12206e2 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -42,17 +42,12 @@ fn list_devices(_device: DeviceWrapper) { let devices = unwrap_ok!(nitrokey::list_devices()); for device in devices { assert!(!device.path.is_empty()); - if let Some(model) = device.model { - match model { - nitrokey::Model::Pro => { - assert!(device.serial_number.is_some()); - let serial_number = device.serial_number.unwrap(); - assert!(serial_number != SerialNumber::empty()); - } - nitrokey::Model::Storage => { - assert_eq!(None, device.serial_number); - } - } + if Some(nitrokey::Model::Storage) == device.model { + assert_eq!(None, device.serial_number); + } else { + assert!(device.serial_number.is_some()); + let serial_number = device.serial_number.unwrap(); + assert!(serial_number != SerialNumber::empty()); } } } @@ -131,17 +126,14 @@ fn connect_path(device: DeviceWrapper) { for device in devices { let connected_device = unwrap_ok!(manager.connect_path(device.path)); assert_eq!(device.model, Some(connected_device.get_model())); - match device.model.unwrap() { - nitrokey::Model::Pro => { - assert!(device.serial_number.is_some()); - assert_ok!( - device.serial_number.unwrap(), - connected_device.get_serial_number() - ); - } - nitrokey::Model::Storage => { - assert_eq!(None, device.serial_number); - } + if nitrokey::Model::Storage == device.model.unwrap() { + assert_eq!(None, device.serial_number); + } else { + assert!(device.serial_number.is_some()); + assert_ok!( + device.serial_number.unwrap(), + connected_device.get_serial_number() + ); } } } |