summaryrefslogtreecommitdiff
path: root/src/tests/pin.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2020-08-24 18:04:20 -0700
committerDaniel Mueller <deso@posteo.net>2020-08-24 18:04:20 -0700
commit0cc4371d138d5e98cd22813f10689cb089eef378 (patch)
tree4b6ab589bc552d8b1990a66cf6e42ad74002f452 /src/tests/pin.rs
parent24250081fe899b2f4ddfcf1fffc812e8c5e7b83e (diff)
downloadnitrocli-0cc4371d138d5e98cd22813f10689cb089eef378.tar.gz
nitrocli-0cc4371d138d5e98cd22813f10689cb089eef378.tar.bz2
Introduce builder-inspired way for configuring 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 allows for an easier configuration of an existing object with builder-pattern-inspired modifier methods.
Diffstat (limited to 'src/tests/pin.rs')
-rw-r--r--src/tests/pin.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tests/pin.rs b/src/tests/pin.rs
index 7770fba..484e256 100644
--- a/src/tests/pin.rs
+++ b/src/tests/pin.rs
@@ -21,7 +21,7 @@ fn unblock(model: nitrokey::Model) -> anyhow::Result<()> {
assert!(device.get_user_retry_count()? < 3);
}
- let _ = Nitrocli::with_model(model).handle(&["pin", "unblock"])?;
+ let _ = Nitrocli::new().model(model).handle(&["pin", "unblock"])?;
{
let mut manager = nitrokey::force_take()?;
@@ -33,9 +33,9 @@ fn unblock(model: nitrokey::Model) -> anyhow::Result<()> {
#[test_device]
fn set_user(model: nitrokey::Model) -> anyhow::Result<()> {
- let mut ncli = Nitrocli::with_model(model);
+ let ncli = Nitrocli::new().model(model);
// Set a new user PIN.
- ncli.new_user_pin("new-pin");
+ let mut ncli = ncli.new_user_pin("new-pin");
let out = ncli.handle(&["pin", "set", "user"])?;
assert!(out.is_empty());
@@ -53,8 +53,9 @@ fn set_user(model: nitrokey::Model) -> anyhow::Result<()> {
}
// Revert to the default user PIN.
- ncli.user_pin("new-pin");
- ncli.new_user_pin(nitrokey::DEFAULT_USER_PIN);
+ let mut ncli = ncli
+ .user_pin("new-pin")
+ .new_user_pin(nitrokey::DEFAULT_USER_PIN);
let out = ncli.handle(&["pin", "set", "user"])?;
assert!(out.is_empty());