Test helpers and unit tests (#26)

* Implement a few utility functions for tests

Most tests would require a test file hierarchy instead of operating on a
live system.

* Add unit tests for `tab::scan_path`

Tests:
* Works on a valid path
* Returns an empty Vec on an invalid directory
* Returns an empty Vec for an empty directory

I also implemented a few test helpers that may be useful for other
unit tests.

* Less spammy test logs and placate Clippy.
This commit is contained in:
Joshua Megnauth 2024-02-01 16:29:10 +00:00 • committed by GitHub
parent 60eeb724d1
commit d6c58991c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 228 additions and 0 deletions

24
Cargo.lock generated
View file

@ -1092,6 +1092,7 @@ dependencies = [
"chrono",
"dirs",
"env_logger",
"fastrand 2.0.1",
"fork",
"i18n-embed",
"i18n-embed-fl",
@ -1104,6 +1105,8 @@ dependencies = [
"rust-embed",
"serde",
"systemicons",
"tempfile",
"test-log",
"tokio",
"trash",
]
@ -5014,6 +5017,27 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "test-log"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6159ab4116165c99fc88cce31f99fa2c9dbe08d3691cb38da02fc3b45f357d2b"
dependencies = [
"env_logger",
"test-log-macros",
]
[[package]]
name = "test-log-macros"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ba277e77219e9eea169e8508942db1bf5d8a41ff2db9b20aab5a5aadc9fa25d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "thiserror"
version = "1.0.56"