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
commitf7cc135a6b6bfa5ff120e75b720e57fc4b22b509 (patch)
tree3562772e54d43eda0d70212fdad625949217bdcc
parent756dc2ed9d16a3edbfdc4778feb11f0b0c84d897 (diff)
downloadnitrocli-f7cc135a6b6bfa5ff120e75b720e57fc4b22b509.tar.gz
nitrocli-f7cc135a6b6bfa5ff120e75b720e57fc4b22b509.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)
}
}