From 1ee836aff66f4f2742e28d5ab2e96259f9307aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Wed, 22 Jan 2025 12:36:27 +0000 Subject: [PATCH] Add test_checkout_pygit2_with_home_env_unset unit test --- tests/pytests/unit/utils/test_gitfs.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/pytests/unit/utils/test_gitfs.py b/tests/pytests/unit/utils/test_gitfs.py index 4b0c11afd60f..c4a9544b05aa 100644 --- a/tests/pytests/unit/utils/test_gitfs.py +++ b/tests/pytests/unit/utils/test_gitfs.py @@ -7,6 +7,7 @@ import salt.fileserver.gitfs import salt.utils.gitfs from salt.exceptions import FileserverConfigError +from tests.support.helpers import patched_environ from tests.support.mock import MagicMock, patch try: @@ -239,6 +240,20 @@ def test_checkout_pygit2(_prepare_provider): assert provider.checkout() is None +@pytest.mark.skipif(not HAS_PYGIT2, reason="This host lacks proper pygit2 support") +@pytest.mark.skip_on_windows( + reason="Skip Pygit2 on windows, due to pygit2 access error on windows" +) +def test_checkout_pygit2_with_home_env_unset(_prepare_provider): + provider = _prepare_provider + provider.remotecallbacks = None + provider.credentials = None + with patched_environ(__cleanup__=["HOME"]): + assert "HOME" not in os.environ + provider.init_remote() + assert "HOME" in os.environ + + @pytest.mark.skipif(not HAS_PYGIT2, reason="This host lacks proper pygit2 support") @pytest.mark.skip_on_windows( reason="Skip Pygit2 on windows, due to pygit2 access error on windows"