Skip to content

Commit

Permalink
Slightly improve quality of test failure messages
Browse files Browse the repository at this point in the history
This uses `assert_eq!` with `None`, instead of `assert!` on an
`is_none()` call, so that we get `left` and `right` expressions
in test failure output.

It also includes some other changes that are just for code
readability: running `cargo fmt`, and replacing an expression in
the tests that evaluates to the same string as `crate::NULL_DEVICE`
with that (as the goal is not to test the value of `NULL_DEVICE`).
  • Loading branch information
EliahKagan committed Aug 28, 2024
1 parent 5723077 commit 9641660
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions gix-path/src/env/git/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ fn exe_info_never_from_local_scope() {
.set("GIT_CONFIG_NOSYSTEM", "1")
.set("GIT_CONFIG_GLOBAL", if cfg!(windows) { "NUL" } else { "/dev/null" });
let maybe_path = super::exe_info();
assert!(
maybe_path.is_none(),
assert_eq!(
maybe_path, None,
"Should find no config path if the config would be local"
);
}
Expand All @@ -399,14 +399,18 @@ fn exe_info_never_from_local_scope_even_if_temp_is_here() {
let _cwd = gix_testtools::set_current_dir(&repo).expect("can change to repo dir");
let _env = gix_testtools::Env::new()
.set("GIT_CONFIG_NOSYSTEM", "1")
.set("GIT_CONFIG_GLOBAL", if cfg!(windows) { "NUL" } else { "/dev/null" })
.set("GIT_CONFIG_GLOBAL", super::NULL_DEVICE)
.set("TMPDIR", repo_str) // Mainly for Unix.
.set("TMP", repo_str) // Mainly for Windows.
.set("TEMP", repo_str); // Mainly for Windows, too.
assert_eq!(std::env::temp_dir(), repo, "It is likely that setting up the test failed");
assert_eq!(
std::env::temp_dir(),
repo,
"It is likely that setting up the test failed"
);
let maybe_path = super::exe_info();
assert!(
maybe_path.is_none(),
assert_eq!(
maybe_path, None,
"Should find no config path if the config would be local even in a `/tmp`-like dir"
);
}
Expand Down

0 comments on commit 9641660

Please sign in to comment.