diff options
author | Daniel Mueller <deso@posteo.net> | 2020-08-24 18:04:20 -0700 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2020-08-24 18:04:20 -0700 |
commit | 0cc4371d138d5e98cd22813f10689cb089eef378 (patch) | |
tree | 4b6ab589bc552d8b1990a66cf6e42ad74002f452 /src/tests/pws.rs | |
parent | 24250081fe899b2f4ddfcf1fffc812e8c5e7b83e (diff) | |
download | nitrocli-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/pws.rs')
-rw-r--r-- | src/tests/pws.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tests/pws.rs b/src/tests/pws.rs index 45c4400..cdead84 100644 --- a/src/tests/pws.rs +++ b/src/tests/pws.rs @@ -7,7 +7,8 @@ use super::*; #[test_device] fn set_invalid_slot(model: nitrokey::Model) { - let err = Nitrocli::with_model(model) + let err = Nitrocli::new() + .model(model) .handle(&["pws", "set", "100", "name", "login", "1234"]) .unwrap_err() .to_string(); @@ -23,7 +24,7 @@ fn status(model: nitrokey::Model) -> anyhow::Result<()> { ) .unwrap(); - let mut ncli = Nitrocli::with_model(model); + let mut ncli = Nitrocli::new().model(model); // Make sure that we have at least something to display by ensuring // that there are there is one slot programmed. let _ = ncli.handle(&["pws", "set", "0", "the-name", "the-login", "123456"])?; @@ -39,7 +40,7 @@ fn set_get(model: nitrokey::Model) -> anyhow::Result<()> { const LOGIN: &str = "d-e-s-o"; const PASSWORD: &str = "my-secret-password"; - let mut ncli = Nitrocli::with_model(model); + let mut ncli = Nitrocli::new().model(model); let _ = ncli.handle(&["pws", "set", "1", &NAME, &LOGIN, &PASSWORD])?; let out = ncli.handle(&["pws", "get", "1", "--quiet", "--name"])?; @@ -71,7 +72,7 @@ fn set_reset_get(model: nitrokey::Model) -> anyhow::Result<()> { const LOGIN: &str = "a\\user"; const PASSWORD: &str = "!@&-)*(&+%^@"; - let mut ncli = Nitrocli::with_model(model); + let mut ncli = Nitrocli::new().model(model); let _ = ncli.handle(&["pws", "set", "2", &NAME, &LOGIN, &PASSWORD])?; let out = ncli.handle(&["reset"])?; @@ -85,7 +86,7 @@ fn set_reset_get(model: nitrokey::Model) -> anyhow::Result<()> { #[test_device] fn clear(model: nitrokey::Model) -> anyhow::Result<()> { - let mut ncli = Nitrocli::with_model(model); + let mut ncli = Nitrocli::new().model(model); let _ = ncli.handle(&["pws", "set", "10", "clear-test", "some-login", "abcdef"])?; let _ = ncli.handle(&["pws", "clear", "10"])?; let res = ncli.handle(&["pws", "get", "10"]); |