diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_git_config.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_git_config.py b/tests/test_git_config.py index 4b4e4cabb..33b0466fa 100644 --- a/tests/test_git_config.py +++ b/tests/test_git_config.py | |||
| @@ -268,3 +268,23 @@ def test_remote_save_with_push_url_without_projectname( | |||
| 268 | def test_is_id(rev: str, expected: bool) -> None: | 268 | def test_is_id(rev: str, expected: bool) -> None: |
| 269 | """Test IsId identifies both SHA-1 and SHA-256 hashes.""" | 269 | """Test IsId identifies both SHA-1 and SHA-256 hashes.""" |
| 270 | assert git_config.IsId(rev) == expected | 270 | assert git_config.IsId(rev) == expected |
| 271 | |||
| 272 | |||
| 273 | def test_repo_config_for_user_is_not_shared_with_git_config( | ||
| 274 | monkeypatch: pytest.MonkeyPatch, tmp_home_dir: Path | ||
| 275 | ) -> None: | ||
| 276 | """RepoConfig.ForUser() must not reuse GitConfig.ForUser()'s cache.""" | ||
| 277 | monkeypatch.setattr(git_config.GitConfig, "_ForUser", None) | ||
| 278 | monkeypatch.setattr(git_config.RepoConfig, "_ForUser", None) | ||
| 279 | monkeypatch.delenv("REPO_CONFIG_DIR", raising=False) | ||
| 280 | |||
| 281 | # Populate the GitConfig cache first, as manifest loading does. | ||
| 282 | git_cfg = git_config.GitConfig.ForUser() | ||
| 283 | repo_cfg = git_config.RepoConfig.ForUser() | ||
| 284 | |||
| 285 | assert repo_cfg is not git_cfg | ||
| 286 | assert git_cfg.file == str(tmp_home_dir / ".gitconfig") | ||
| 287 | assert repo_cfg.file == str(tmp_home_dir / ".repoconfig" / "config") | ||
| 288 | # And the RepoConfig instance is cached on its own class. | ||
| 289 | assert git_config.RepoConfig.ForUser() is repo_cfg | ||
| 290 | assert git_config.GitConfig.ForUser() is git_cfg | ||
