From 0f163477f63d533f90b61c1f39423712567bf7ea Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 25 Jan 2020 21:07:07 +0100 Subject: Refactor connection handling This patch introduces two new functions, find_device and connect, to connect to a Nitrokey device. find_device queries the attached Nitrokey devices, applies the filters (currently only the --model option) and returns the first match. connect calls find_device and connects to the returned device. This refactoring allows us to add more device filters, for example a --serial-number option, without code duplication. --- src/tests/status.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/tests') diff --git a/src/tests/status.rs b/src/tests/status.rs index d158103..fe69d78 100644 --- a/src/tests/status.rs +++ b/src/tests/status.rs @@ -11,12 +11,7 @@ fn not_found_raw() { assert_ne!(rc, 0); assert_eq!(out, b""); - let expected = r#"Nitrokey device not found - -Caused by: - Communication error: Could not connect to a Nitrokey device -"#; - assert_eq!(err, expected.as_bytes()); + assert_eq!(err, b"Nitrokey device not found\n"); } #[test_device] -- cgit v1.2.1