From c72a9b27a596e6b9ad044765de56cbed765eee90 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sat, 10 Aug 2024 06:16:52 +0000 Subject: [PATCH] Unset GIT_ASKPASS in tests that assume it is unset Two of the askpass tests assume `GIT_ASKPASS` is not set. Before this change, they wrongly fail when it is set, even if the code under test is working correctly. 1. ssh_askpass_is_used_as_fallback 2. ssh_askpass_does_not_override_current_value As other tests that deliberately involve `GIT_ASKPASS` (and therefore do not need to be modified) attest, when it is set: 1. `SSH_ASKPASS` is not used as a fallback (`GIT_ASKPASS` deliberately takes precedence). 2. Although `SSH_ASKPASS` still does not override the current value, `GIT_ASKPASS` does override it, so checking for equality to the current value fails. Since those test cases are among those that already have the `serial` attribute and already temporarily modify the environment, this extends that modification by having it also temporarily unset `GIT_ASKPASS` if it was set. --- gix-prompt/tests/options/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gix-prompt/tests/options/mod.rs b/gix-prompt/tests/options/mod.rs index d8e821b9cd2..6c8fcccf839 100644 --- a/gix-prompt/tests/options/mod.rs +++ b/gix-prompt/tests/options/mod.rs @@ -45,7 +45,7 @@ mod apply_environment { #[test] #[serial] fn ssh_askpass_is_used_as_fallback() { - let _env = Env::new().set("SSH_ASKPASS", "fallback"); + let _env = Env::new().unset("GIT_ASKPASS").set("SSH_ASKPASS", "fallback"); assert_eq!( Options { @@ -63,7 +63,7 @@ mod apply_environment { #[test] #[serial] fn ssh_askpass_does_not_override_current_value() { - let _env = Env::new().set("SSH_ASKPASS", "fallback"); + let _env = Env::new().unset("GIT_ASKPASS").set("SSH_ASKPASS", "fallback"); assert_eq!( Options {