diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_project.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_project.py b/tests/test_project.py index 46bc7f1fa..249cbd072 100644 --- a/tests/test_project.py +++ b/tests/test_project.py | |||
| @@ -2420,6 +2420,33 @@ class StatelessSyncTests(unittest.TestCase): | |||
| 2420 | self.assertTrue(res.success) | 2420 | self.assertTrue(res.success) |
| 2421 | self.assertFalse(getattr(proj, "stateless_prune_needed", False)) | 2421 | self.assertFalse(getattr(proj, "stateless_prune_needed", False)) |
| 2422 | 2422 | ||
| 2423 | def test_sync_network_half_stateless_skips_without_worktree(self) -> None: | ||
| 2424 | """Test stateless sync doesn't prune a project with no worktree.""" | ||
| 2425 | with utils_for_test.TempGitTree() as tempdir: | ||
| 2426 | proj = self._get_project(tempdir) | ||
| 2427 | proj.worktree = os.path.join(tempdir, "missing") | ||
| 2428 | proj._HasDirtyOrStash = mock.MagicMock(return_value=False) | ||
| 2429 | |||
| 2430 | res = proj.Sync_NetworkHalf() | ||
| 2431 | |||
| 2432 | self.assertTrue(res.success) | ||
| 2433 | self.assertFalse(proj.stateless_prune_needed) | ||
| 2434 | proj._LsRemote.assert_not_called() | ||
| 2435 | proj._HasDirtyOrStash.assert_not_called() | ||
| 2436 | |||
| 2437 | def test_ls_remote_runs_without_worktree(self) -> None: | ||
| 2438 | """Test ls-remote only needs the gitdir's remote config.""" | ||
| 2439 | with utils_for_test.TempGitTree() as tempdir: | ||
| 2440 | proj = _create_mock_project(tempdir) | ||
| 2441 | proj.work_git.commit("--allow-empty", "-m", "initial") | ||
| 2442 | proj.work_git.config("remote.origin.url", tempdir) | ||
| 2443 | head = proj.work_git.rev_parse("HEAD") | ||
| 2444 | proj.worktree = os.path.join(tempdir, "missing") | ||
| 2445 | # _create_mock_project() stubs this out. | ||
| 2446 | del proj._LsRemote | ||
| 2447 | |||
| 2448 | self.assertEqual(f"{head}\tHEAD\n", proj._LsRemote("HEAD")) | ||
| 2449 | |||
| 2423 | def test_sync_network_half_stateless_skips_if_local_commits(self): | 2450 | def test_sync_network_half_stateless_skips_if_local_commits(self): |
| 2424 | """Test stateless sync skips if there are local-only commits.""" | 2451 | """Test stateless sync skips if there are local-only commits.""" |
| 2425 | with utils_for_test.TempGitTree() as tempdir: | 2452 | with utils_for_test.TempGitTree() as tempdir: |
