diff options
author | Daniel Mueller <deso@posteo.net> | 2019-01-10 13:49:48 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-01-10 13:49:48 -0800 |
commit | 749a5c78c2075c5d37b01ec4fd23704aa5cfdf09 (patch) | |
tree | 0c547995a46cc93ca94c0b09900cd372bfaf5cb7 /nitrocli/src/tests/status.rs | |
parent | 886788a95a3c79a7664cbcd0bfffa1e500461adf (diff) | |
download | nitrocli-749a5c78c2075c5d37b01ec4fd23704aa5cfdf09.tar.gz nitrocli-749a5c78c2075c5d37b01ec4fd23704aa5cfdf09.tar.bz2 |
Refactor integration test code internals for program invocation
In the future we will need to perform a sequence of invocations of the
program for testing purposes, with each having a slightly different
execution context. Such a scheme does not map very well to the existing
design where we essentially just have a function invocation to run the
program. We would either have functions that produce a different
execution context or pass in the data to modify.
Neither of these approaches is appealing and so this change reworks the
code slightly. With it, we now can create a Nitrocli object, which
contains the data that diverges from the default execution context. This
data will eventually be modifiable by callers.
Diffstat (limited to 'nitrocli/src/tests/status.rs')
-rw-r--r-- | nitrocli/src/tests/status.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/nitrocli/src/tests/status.rs b/nitrocli/src/tests/status.rs index 838ebc9..acd33dc 100644 --- a/nitrocli/src/tests/status.rs +++ b/nitrocli/src/tests/status.rs @@ -18,13 +18,12 @@ // ************************************************************************* use super::*; -use crate::tests::nitrocli; // This test acts as verification that conversion of Error::Error // variants into the proper exit code works properly. #[test_device] fn not_found_raw() { - let (rc, out, err) = nitrocli::run(NO_DEV, &["status"]); + let (rc, out, err) = Nitrocli::new().run(&["status"]); assert_ne!(rc, 0); assert_eq!(out, b""); @@ -33,7 +32,7 @@ fn not_found_raw() { #[test_device] fn not_found() { - let res = nitrocli::handle(NO_DEV, &["status"]); + let res = Nitrocli::new().handle(&["status"]); assert_eq!(res.unwrap_str_err(), "Nitrokey device not found"); } @@ -50,7 +49,7 @@ $"#, ) .unwrap(); - let out = nitrocli::handle(Some(device), &["status"])?; + let out = Nitrocli::with_dev(device).handle(&["status"])?; assert!(re.is_match(&out), out); Ok(()) } |