diff options
author | Joanna Wang <jojwang@google.com> | 2022-12-08 17:46:28 -0500 |
---|---|---|
committer | Joanna Wang <jojwang@google.com> | 2022-12-09 14:25:15 +0000 |
commit | 0e4f1e7fba4770908235e136c5ed0a540854651e (patch) | |
tree | c3eb6353851271730e5a3355fc70fbdb0a5fb346 /tests/test_git_superproject.py | |
parent | e81528649236ec9fb5983191767a96dc30acff54 (diff) | |
download | git-repo-0e4f1e7fba4770908235e136c5ed0a540854651e.tar.gz |
Use --negotiation-tip in superproject fetches.
Bug: b/260645739
Change-Id: Ib0cdbb13f130b91ab14df9c60a510f1e27cca8e0
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/354354
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Joanna Wang <jojwang@google.com>
Diffstat (limited to 'tests/test_git_superproject.py')
-rw-r--r-- | tests/test_git_superproject.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index 225e98c2..49295d83 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py | |||
@@ -21,6 +21,7 @@ import tempfile | |||
21 | import unittest | 21 | import unittest |
22 | from unittest import mock | 22 | from unittest import mock |
23 | 23 | ||
24 | from git_command import GitCommand | ||
24 | import git_superproject | 25 | import git_superproject |
25 | import git_trace2_event_log | 26 | import git_trace2_event_log |
26 | import manifest_xml | 27 | import manifest_xml |
@@ -364,3 +365,41 @@ class SuperprojectTestCase(unittest.TestCase): | |||
364 | 'revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f"/>' | 365 | 'revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f"/>' |
365 | '<superproject name="superproject"/>' | 366 | '<superproject name="superproject"/>' |
366 | '</manifest>') | 367 | '</manifest>') |
368 | |||
369 | def test_Fetch(self): | ||
370 | manifest = self.getXmlManifest(""" | ||
371 | <manifest> | ||
372 | <remote name="default-remote" fetch="http://localhost" /> | ||
373 | <default remote="default-remote" revision="refs/heads/main" /> | ||
374 | <superproject name="superproject"/> | ||
375 | " /></manifest> | ||
376 | """) | ||
377 | self.maxDiff = None | ||
378 | self._superproject = git_superproject.Superproject( | ||
379 | manifest, name='superproject', | ||
380 | remote=manifest.remotes.get('default-remote').ToRemoteSpec('superproject'), | ||
381 | revision='refs/heads/main') | ||
382 | os.mkdir(self._superproject._superproject_path) | ||
383 | os.mkdir(self._superproject._work_git) | ||
384 | with mock.patch.object(self._superproject, '_Init', return_value=True): | ||
385 | with mock.patch('git_superproject.GitCommand', autospec=True) as mock_git_command: | ||
386 | with mock.patch('git_superproject.GitRefs.get', autospec=True) as mock_git_refs: | ||
387 | instance = mock_git_command.return_value | ||
388 | instance.Wait.return_value = 0 | ||
389 | mock_git_refs.side_effect = ['', '1234'] | ||
390 | |||
391 | self.assertTrue(self._superproject._Fetch()) | ||
392 | self.assertEqual(mock_git_command.call_args.args,(None, [ | ||
393 | 'fetch', 'http://localhost/superproject', '--depth', '1', | ||
394 | '--force', '--no-tags', '--filter', 'blob:none', | ||
395 | 'refs/heads/main:refs/heads/main' | ||
396 | ])) | ||
397 | |||
398 | # If branch for revision exists, set as --negotiation-tip. | ||
399 | self.assertTrue(self._superproject._Fetch()) | ||
400 | self.assertEqual(mock_git_command.call_args.args,(None, [ | ||
401 | 'fetch', 'http://localhost/superproject', '--depth', '1', | ||
402 | '--force', '--no-tags', '--filter', 'blob:none', | ||
403 | '--negotiation-tip', '1234', | ||
404 | 'refs/heads/main:refs/heads/main' | ||
405 | ])) | ||