aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/tests/config.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-08-31 10:34:34 -0700
committerDaniel Mueller <deso@posteo.net>2019-08-31 10:34:34 -0700
commit7e2adff71e293eef2570a6a8e43127bfab569cb3 (patch)
tree6e8d0ae565e480c5540b2975384882497130ed5b /nitrocli/src/tests/config.rs
parentfb55bcb2e1330086c3c39f5f9dcbd67aaf6fd1b3 (diff)
downloadnitrocli-7e2adff71e293eef2570a6a8e43127bfab569cb3.tar.gz
nitrocli-7e2adff71e293eef2570a6a8e43127bfab569cb3.tar.bz2
Introduce builder infrastructure for assembling Nitrocli instance
In the future we would like to provide more ways for tests to create a Nitrocli instance. In order to prevent explosion of with_XXX methods for each possible combination of arguments, this change introduces a Builder struct that can be used to create such an instance in an idiomatic way.
Diffstat (limited to 'nitrocli/src/tests/config.rs')
-rw-r--r--nitrocli/src/tests/config.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/nitrocli/src/tests/config.rs b/nitrocli/src/tests/config.rs
index ea3a0e8..4370b87 100644
--- a/nitrocli/src/tests/config.rs
+++ b/nitrocli/src/tests/config.rs
@@ -31,14 +31,23 @@ $"#,
)
.unwrap();
- let out = Nitrocli::with_model(model).handle(&["config", "get"])?;
+ let out = Nitrocli::make()
+ .model(model)
+ .build()
+ .handle(&["config", "get"])?;
+
assert!(re.is_match(&out), out);
Ok(())
}
#[test_device]
fn set_wrong_usage(model: nitrokey::Model) {
- let res = Nitrocli::with_model(model).handle(&["config", "set", "--numlock", "2", "-N"]);
+ let res =
+ Nitrocli::make()
+ .model(model)
+ .build()
+ .handle(&["config", "set", "--numlock", "2", "-N"]);
+
assert_eq!(
res.unwrap_str_err(),
"--numlock and --no-numlock are mutually exclusive"
@@ -47,7 +56,7 @@ fn set_wrong_usage(model: nitrokey::Model) {
#[test_device]
fn set_get(model: nitrokey::Model) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_model(model);
+ let mut ncli = Nitrocli::make().model(model).build();
let _ = ncli.handle(&["config", "set", "-s", "1", "-c", "0", "-N"])?;
let re = regex::Regex::new(