Skip to content

Commit

Permalink
add ui snapshot tests
Browse files Browse the repository at this point in the history
these tests are used to assert on Ouch's output for error reports and
progress logging
  • Loading branch information
marcospb19 committed Sep 16, 2023
1 parent e1a1af9 commit dc25ede
Show file tree
Hide file tree
Showing 14 changed files with 394 additions and 16 deletions.
141 changes: 127 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ clap_mangen = "0.2.13"
[dev-dependencies]
assert_cmd = "2.0.12"
infer = "0.15.0"
insta = "1.31.0"
parse-display = "0.8.2"
proptest = "1.2.0"
rand = { version = "0.8.5", default-features = false, features = ["small_rng", "std"] }
Expand Down
14 changes: 14 additions & 0 deletions tests/snapshots/ui__ui_test_err_compress_missing_extension.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch compress input output\", dir)"
---
[ERROR] Cannot compress to 'output'.
- You shall supply the compression format

hint: Try adding supported extensions (see --help):
hint: ouch compress <FILES>... output.tar.gz
hint: ouch compress <FILES>... output.zip
hint:
hint: Alternatively, you can overwrite this option by using the '--format' flag:
hint: ouch compress <FILES>... output --format tar.gz

14 changes: 14 additions & 0 deletions tests/snapshots/ui__ui_test_err_decompress_missing_extension.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch decompress a\", dir)"
---
[ERROR] Cannot decompress files without extensions
- Files without supported extensions: <FOLDER>/a
- Decompression formats are detected automatically by the file extension

hint: Provide a file with a supported extension:
hint: ouch decompress example.tar.gz
hint:
hint: Or overwrite this option with the '--format' flag:
hint: ouch decompress <FOLDER>/a --format tar.gz

7 changes: 7 additions & 0 deletions tests/snapshots/ui__ui_test_err_missing_files-2.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch decompress a b\", dir)"
---
[ERROR] failed to canonicalize path `a`
- File not found

7 changes: 7 additions & 0 deletions tests/snapshots/ui__ui_test_err_missing_files-3.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch list a b\", dir)"
---
[ERROR] failed to canonicalize path `a`
- File not found

7 changes: 7 additions & 0 deletions tests/snapshots/ui__ui_test_err_missing_files.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch compress a b\", dir)"
---
[ERROR] failed to canonicalize path `a`
- File not found

6 changes: 6 additions & 0 deletions tests/snapshots/ui__ui_test_ok_compress-2.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch compress input output.gz\", dir)"
---
[INFO] Successfully compressed 'output.gz'.

7 changes: 7 additions & 0 deletions tests/snapshots/ui__ui_test_ok_compress.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch compress input output.zip\", dir)"
---
[INFO] Compressing 'input'.
[INFO] Successfully compressed 'output.zip'.

8 changes: 8 additions & 0 deletions tests/snapshots/ui__ui_test_ok_decompress.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
source: tests/ui.rs
expression: "run_ouch(\"ouch decompress output.zst\", dir)"
---
[INFO] Failed to confirm the format of `output` by sniffing the contents, file might be misnamed
[INFO] Successfully decompressed archive in current directory.
[INFO] Files unpacked: 1

25 changes: 25 additions & 0 deletions tests/snapshots/ui__ui_test_usage_help_flag-2.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
source: tests/ui.rs
expression: "output_to_string(ouch!(\"-h\"))"
---
A command-line utility for easily compressing and decompressing files and directories.

Usage: ouch [OPTIONS] <COMMAND>

Commands:
compress Compress one or more files into one output file [aliases: c]
decompress Decompresses one or more files, optionally into another folder [aliases: d]
list List contents of an archive [aliases: l, ls]
help Print this message or the help of the given subcommand(s)

Options:
-y, --yes Skip [Y/n] questions positively
-n, --no Skip [Y/n] questions negatively
-A, --accessible Activate accessibility mode, reducing visual noise [env: ACCESSIBLE=]
-H, --hidden Ignores hidden files
-q, --quiet Silences output
-g, --gitignore Ignores files matched by git's ignore files
-f, --format <FORMAT> Specify the format of the archive
-h, --help Print help (see more with '--help')
-V, --version Print version

Loading

0 comments on commit dc25ede

Please sign in to comment.