aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2020-07-09 20:10:21 -0700
committerDaniel Mueller <deso@posteo.net>2020-07-09 20:10:21 -0700
commitdf34b6565fdcc6cadedac9c42e6091bc3c6798c0 (patch)
tree3562772e54d43eda0d70212fdad625949217bdcc
parent0328fc29bc56498e2312b68e04db828dd1186d23 (diff)
downloadnitrocli-df34b6565fdcc6cadedac9c42e6091bc3c6798c0.tar.gz
nitrocli-df34b6565fdcc6cadedac9c42e6091bc3c6798c0.tar.bz2
Refrain from using Error::Error variant in pinentry tests
The pinentry tests currently expect the Error::Error variant to be reported for failures. This patch adjusts the tests to merely compare strings and ignore the exact type of error. Doing so will make it easier to switch to using anyhow for error handling.
-rw-r--r--src/pinentry.rs27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/pinentry.rs b/src/pinentry.rs
index d1387f4..e1dec3e 100644
--- a/src/pinentry.rs
+++ b/src/pinentry.rs
@@ -348,26 +348,16 @@ mod tests {
let response = "ERR ".to_string() + error + "\n";
let expected = error;
- let error = parse_pinentry_pin(response);
-
- if let Error::Error(ref e) = error.err().unwrap() {
- assert_eq!(e, &expected);
- } else {
- panic!("Unexpected result");
- }
+ let error = parse_pinentry_pin(response).unwrap_err();
+ assert_eq!(error.to_string(), expected)
}
#[test]
fn parse_pinentry_pin_unexpected() {
let response = "foobar\n";
let expected = format!("Unexpected response: {}", response);
- let error = parse_pinentry_pin(response);
-
- if let Error::Error(ref e) = error.err().unwrap() {
- assert_eq!(e, &expected);
- } else {
- panic!("Unexpected result");
- }
+ let error = parse_pinentry_pin(response).unwrap_err();
+ assert_eq!(error.to_string(), expected)
}
#[test]
@@ -384,12 +374,7 @@ mod tests {
fn parse_pinentry_response_unexpected() {
let response = "ERR 42";
let expected = format!("Unexpected response: {}", response);
- let error = parse_pinentry_response(response);
-
- if let Error::Error(ref e) = error.err().unwrap() {
- assert_eq!(e, &expected);
- } else {
- panic!("Unexpected result");
- }
+ let error = parse_pinentry_response(response).unwrap_err();
+ assert_eq!(error.to_string(), expected)
}
}