aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/tests/mod.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-07-17 19:14:03 -0700
committerDaniel Mueller <deso@posteo.net>2019-07-17 19:14:03 -0700
commit21fde5e01b7db9a8f3847ae351f15ab0582feda2 (patch)
treecd64f9a3bbbf342a0451c5a699f5f0c394a3a338 /nitrocli/src/tests/mod.rs
parent49f5194e16db47b6de9847b79840c6fe35e0df8c (diff)
downloadnitrocli-21fde5e01b7db9a8f3847ae351f15ab0582feda2.tar.gz
nitrocli-21fde5e01b7db9a8f3847ae351f15ab0582feda2.tar.bz2
Update nitrokey crate to 0.4.0-alpha.0
This is patch marks the first step in the process of updating the nitrokey dependency to version 0.4. In particular, it integrates with the first alpha version. The main change on the nitrocli side accompanying the version bump is that the nitrokey::CommandError got replaced by a more general nitrokey::Error which includes the former variant. Import subrepo nitrokey/:nitrokey at d433189caefe6bd6c88da7fbb1d6e9304353eb83
Diffstat (limited to 'nitrocli/src/tests/mod.rs')
-rw-r--r--nitrocli/src/tests/mod.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/nitrocli/src/tests/mod.rs b/nitrocli/src/tests/mod.rs
index 2f2926f..0ebc783 100644
--- a/nitrocli/src/tests/mod.rs
+++ b/nitrocli/src/tests/mod.rs
@@ -54,6 +54,8 @@ pub trait UnwrapError {
fn unwrap_str_err(self) -> String;
/// Unwrap a Error::CommandError variant.
fn unwrap_cmd_err(self) -> (Option<&'static str>, nitrokey::CommandError);
+ /// Unwrap a Error::LibraryError variant.
+ fn unwrap_lib_err(self) -> (Option<&'static str>, nitrokey::LibraryError);
}
impl<T> UnwrapError for crate::Result<T>
@@ -69,7 +71,20 @@ where
fn unwrap_cmd_err(self) -> (Option<&'static str>, nitrokey::CommandError) {
match self.unwrap_err() {
- crate::Error::CommandError(ctx, err) => (ctx, err),
+ crate::Error::NitrokeyError(ctx, err) => match err {
+ nitrokey::Error::CommandError(err) => (ctx, err),
+ err => panic!("Unexpected error variant found: {:?}", err),
+ },
+ err => panic!("Unexpected error variant found: {:?}", err),
+ }
+ }
+
+ fn unwrap_lib_err(self) -> (Option<&'static str>, nitrokey::LibraryError) {
+ match self.unwrap_err() {
+ crate::Error::NitrokeyError(ctx, err) => match err {
+ nitrokey::Error::LibraryError(err) => (ctx, err),
+ err => panic!("Unexpected error variant found: {:?}", err),
+ },
err => panic!("Unexpected error variant found: {:?}", err),
}
}