fix(tests): prevent registry corruption via CWD leak and unmocked calls #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a critical issue where the test suite was leaking the Current Working Directory (CWD) state between tests and inadvertently modifying the user's actual
~/.local/state/git-pulsar/registry.The Problem
Several tests in
tests/test_cli.pywere usingos.chdir(tmp_path)to switch to a temporary test directory but were not resetting it.os.chdiris used without cleanup, the process remains in the temp folder for all subsequent tests.test_main_triggers_bootstrapwas falling through tosetup_repo(), which (because it wasn't mocked) registered the leaked temp directory into the user's realregistryfile.The Fix
monkeypatch.chdir: Replaced all instances ofos.chdir(tmp_path)withmonkeypatch.chdir(tmp_path)intests/test_cli.py. This ensures the CWD is automatically restored to its original state after each test.setup_repo: Added a mock forgit_pulsar.cli.setup_repointest_main_triggers_bootstrapto ensure it never attempts to run real setup logic during the test.Changes
tests/test_cli.py:test_setup_repo_initializes_gittest_main_triggers_bootstraptest_pause_commandtest_status_reports_pause_statetest_diff_shows_untracked_filesVerification
pytest.~/.local/state/git-pulsar/registryis no longer modified during test runs.