Skip to content

Commit 754eeb4

Browse files
committed
Add snapshot tests for the help output
As a preparation for the migration from structopt to clap 3.0.0, we add tests for the help output of all commands.
1 parent 03c9199 commit 754eeb4

File tree

65 files changed

+1891
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1891
-0
lines changed

Cargo.lock

+131
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ version = "1.5.5"
7272
[dependencies.toml]
7373
version = "0.5.6"
7474

75+
[dev-dependencies.insta]
76+
version = "1.8"
77+
7578
[dev-dependencies.nitrokey-test]
7679
version = "0.5"
7780

src/tests/run.rs

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ fn help_options() {
4444
args.insert(0, "nitrocli");
4545
assert!(s.starts_with(&args.join("-")), "{}", s);
4646
assert!(s.contains("USAGE:\n"), "{}", s);
47+
48+
insta::assert_snapshot!(format!("{}_{}", args.join("_"), help), s);
4749
}
4850

4951
fn test(args: &[&str]) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
source: src/tests/run.rs
3+
expression: s
4+
5+
---
6+
nitrocli 0.4.1
7+
A top-level command for nitrocli
8+
9+
USAGE:
10+
nitrocli [FLAGS] [OPTIONS] <SUBCOMMAND>
11+
12+
FLAGS:
13+
-h, --help Prints help information
14+
--no-cache Disables the cache for all secrets
15+
-V, --version Prints version information
16+
-v, --verbose Increases the log level (can be supplied multiple times)
17+
18+
OPTIONS:
19+
-m, --model <model> Selects the device model to connect to [possible values: librem, pro,
20+
storage]
21+
--serial-number <serial-numbers>... Sets the serial number of the device to connect to. Can be set multiple
22+
times to allow multiple serial numbers
23+
--usb-path <usb-path> Sets the USB path of the device to connect to
24+
25+
SUBCOMMANDS:
26+
config Reads or writes the device configuration
27+
encrypted Interacts with the device's encrypted volume
28+
fill Fills the SD card with random data
29+
help Prints this message or the help of the given subcommand(s)
30+
hidden Interacts with the device's hidden volume
31+
list Lists the attached Nitrokey devices
32+
lock Locks the connected Nitrokey device
33+
otp Accesses one-time passwords
34+
pin Manages the Nitrokey PINs
35+
pws Accesses the password safe
36+
reset Performs a factory reset
37+
status Prints the status of the connected Nitrokey device
38+
unencrypted Interacts with the device's unencrypted volume
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
source: src/tests/run.rs
3+
expression: s
4+
5+
---
6+
nitrocli 0.4.1
7+
A top-level command for nitrocli
8+
9+
USAGE:
10+
nitrocli [FLAGS] [OPTIONS] <SUBCOMMAND>
11+
12+
FLAGS:
13+
-h, --help Prints help information
14+
--no-cache Disables the cache for all secrets
15+
-V, --version Prints version information
16+
-v, --verbose Increases the log level (can be supplied multiple times)
17+
18+
OPTIONS:
19+
-m, --model <model> Selects the device model to connect to [possible values: librem, pro,
20+
storage]
21+
--serial-number <serial-numbers>... Sets the serial number of the device to connect to. Can be set multiple
22+
times to allow multiple serial numbers
23+
--usb-path <usb-path> Sets the USB path of the device to connect to
24+
25+
SUBCOMMANDS:
26+
config Reads or writes the device configuration
27+
encrypted Interacts with the device's encrypted volume
28+
fill Fills the SD card with random data
29+
help Prints this message or the help of the given subcommand(s)
30+
hidden Interacts with the device's hidden volume
31+
list Lists the attached Nitrokey devices
32+
lock Locks the connected Nitrokey device
33+
otp Accesses one-time passwords
34+
pin Manages the Nitrokey PINs
35+
pws Accesses the password safe
36+
reset Performs a factory reset
37+
status Prints the status of the connected Nitrokey device
38+
unencrypted Interacts with the device's unencrypted volume
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
source: src/tests/run.rs
3+
expression: s
4+
5+
---
6+
nitrocli-config 0.4.1
7+
Reads or writes the device configuration
8+
9+
USAGE:
10+
nitrocli config [FLAGS] [OPTIONS] <SUBCOMMAND>
11+
12+
FLAGS:
13+
-h, --help Prints help information
14+
--no-cache Disables the cache for all secrets
15+
-V, --version Prints version information
16+
-v, --verbose Increases the log level (can be supplied multiple times)
17+
18+
OPTIONS:
19+
-m, --model <model> Selects the device model to connect to [possible values: librem, pro,
20+
storage]
21+
--serial-number <serial-numbers>... Sets the serial number of the device to connect to. Can be set multiple
22+
times to allow multiple serial numbers
23+
--usb-path <usb-path> Sets the USB path of the device to connect to
24+
25+
SUBCOMMANDS:
26+
get Prints the Nitrokey configuration
27+
help Prints this message or the help of the given subcommand(s)
28+
set Changes the Nitrokey configuration
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
source: src/tests/run.rs
3+
expression: s
4+
5+
---
6+
nitrocli-config 0.4.1
7+
Reads or writes the device configuration
8+
9+
USAGE:
10+
nitrocli config [FLAGS] [OPTIONS] <SUBCOMMAND>
11+
12+
FLAGS:
13+
-h, --help Prints help information
14+
--no-cache Disables the cache for all secrets
15+
-V, --version Prints version information
16+
-v, --verbose Increases the log level (can be supplied multiple times)
17+
18+
OPTIONS:
19+
-m, --model <model> Selects the device model to connect to [possible values: librem, pro,
20+
storage]
21+
--serial-number <serial-numbers>... Sets the serial number of the device to connect to. Can be set multiple
22+
times to allow multiple serial numbers
23+
--usb-path <usb-path> Sets the USB path of the device to connect to
24+
25+
SUBCOMMANDS:
26+
get Prints the Nitrokey configuration
27+
help Prints this message or the help of the given subcommand(s)
28+
set Changes the Nitrokey configuration
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
source: src/tests/run.rs
3+
expression: s
4+
5+
---
6+
nitrocli-config-get 0.4.1
7+
Prints the Nitrokey configuration
8+
9+
USAGE:
10+
nitrocli config get [FLAGS] [OPTIONS]
11+
12+
FLAGS:
13+
-h, --help Prints help information
14+
--no-cache Disables the cache for all secrets
15+
-V, --version Prints version information
16+
-v, --verbose Increases the log level (can be supplied multiple times)
17+
18+
OPTIONS:
19+
-m, --model <model> Selects the device model to connect to [possible values: librem, pro,
20+
storage]
21+
--serial-number <serial-numbers>... Sets the serial number of the device to connect to. Can be set multiple
22+
times to allow multiple serial numbers
23+
--usb-path <usb-path> Sets the USB path of the device to connect to
24+

0 commit comments

Comments
 (0)