summaryrefslogtreecommitdiff
path: root/src/tests/status.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-25 21:07:07 +0100
committerDaniel Mueller <deso@posteo.net>2021-01-10 17:37:55 -0800
commit0f163477f63d533f90b61c1f39423712567bf7ea (patch)
treef8bac7008f382e9b0dd425ed75422e9a9af7938f /src/tests/status.rs
parent0cc4371d138d5e98cd22813f10689cb089eef378 (diff)
downloadnitrocli-0f163477f63d533f90b61c1f39423712567bf7ea.tar.gz
nitrocli-0f163477f63d533f90b61c1f39423712567bf7ea.tar.bz2
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.
Diffstat (limited to 'src/tests/status.rs')
-rw-r--r--src/tests/status.rs7
1 files changed, 1 insertions, 6 deletions
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]