diff options
author | Daniel Mueller <deso@posteo.net> | 2019-01-05 17:46:42 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-01-05 17:46:42 -0800 |
commit | ba506bfa085064b9be3e262806d2f5f4ca522aee (patch) | |
tree | 65b2faf2fc9e5cb897928ba85aa3445974b74709 /nitrocli/src/error.rs | |
parent | b4516220b95743b485b9bcd8226285255be9c9c4 (diff) | |
download | nitrocli-ba506bfa085064b9be3e262806d2f5f4ca522aee.tar.gz nitrocli-ba506bfa085064b9be3e262806d2f5f4ca522aee.tar.bz2 |
Add first set of integration tests
This change introduces the first set of integration-style test for the
application. Those tests may or may not connect to an actual Nitrokey
device (depending on what they test). We use the nitrokey-test crate's
test attribute macro to automatically dispatch tests to connected
devices or skip them if a required device is not present. It also
provides the means for automatically serializing tests.
Diffstat (limited to 'nitrocli/src/error.rs')
-rw-r--r-- | nitrocli/src/error.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nitrocli/src/error.rs b/nitrocli/src/error.rs index 738e689..c2a16a2 100644 --- a/nitrocli/src/error.rs +++ b/nitrocli/src/error.rs @@ -24,11 +24,18 @@ use std::string; #[derive(Debug)] pub enum Error { ArgparseError(i32), + CommandError(nitrokey::CommandError), IoError(io::Error), Utf8Error(string::FromUtf8Error), Error(String), } +impl From<nitrokey::CommandError> for Error { + fn from(e: nitrokey::CommandError) -> Error { + Error::CommandError(e) + } +} + impl From<io::Error> for Error { fn from(e: io::Error) -> Error { Error::IoError(e) @@ -45,6 +52,7 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::ArgparseError(_) => write!(f, "Could not parse arguments"), + Error::CommandError(ref e) => write!(f, "Command error: {}", e), Error::Utf8Error(_) => write!(f, "Encountered UTF-8 conversion error"), Error::IoError(ref e) => write!(f, "IO error: {}", e), Error::Error(ref e) => write!(f, "{}", e), |