From ea5239ddd930624532cd1d0edccc0f3e74bec73f Mon Sep 17 00:00:00 2001 From: Joanna Wang Date: Fri, 2 Dec 2022 09:47:29 -0500 Subject: Fix ManifestProject.partial_clone_exclude property. Bug: b/256358360 Change-Id: Ic6e3a049aa38827123d0324c8b14157562c5986e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353574 Reviewed-by: Mike Frysinger Tested-by: Joanna Wang Reviewed-by: Josip Sokcevic --- tests/test_project.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'tests/test_project.py') diff --git a/tests/test_project.py b/tests/test_project.py index 47018d1c..7d07b705 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -22,6 +22,7 @@ import tempfile import unittest import error +import manifest_xml import git_command import git_config import platform_utils @@ -411,3 +412,81 @@ class MigrateWorkTreeTests(unittest.TestCase): self.assertTrue((dotgit / name).is_file()) for name in self._SYMLINKS: self.assertTrue((dotgit / name).is_symlink()) + + +class ManifestPropertiesFetchedCorrectly(unittest.TestCase): + """Ensure properties are fetched properly.""" + + def setUpManifest(self, tempdir): + repo_trace._TRACE_FILE = os.path.join(tempdir, 'TRACE_FILE_from_test') + + repodir = os.path.join(tempdir, '.repo') + manifest_dir = os.path.join(repodir, 'manifests') + manifest_file = os.path.join( + repodir, manifest_xml.MANIFEST_FILE_NAME) + local_manifest_dir = os.path.join( + repodir, manifest_xml.LOCAL_MANIFESTS_DIR_NAME) + os.mkdir(repodir) + os.mkdir(manifest_dir) + manifest = manifest_xml.XmlManifest(repodir, manifest_file) + + return project.ManifestProject( + manifest, 'test/manifest', os.path.join(tempdir, '.git'), tempdir) + + def test_manifest_config_properties(self): + """Test we are fetching the manifest config properties correctly.""" + + with TempGitTree() as tempdir: + fakeproj = self.setUpManifest(tempdir) + + # Set property using the expected Set method, then ensure + # the porperty functions are using the correct Get methods. + fakeproj.config.SetString( + 'manifest.standalone', 'https://chicken/manifest.git') + self.assertEqual( + fakeproj.standalone_manifest_url, 'https://chicken/manifest.git') + + fakeproj.config.SetString('manifest.groups', 'test-group, admin-group') + self.assertEqual(fakeproj.manifest_groups, 'test-group, admin-group') + + fakeproj.config.SetString('repo.reference', 'mirror/ref') + self.assertEqual(fakeproj.reference, 'mirror/ref') + + fakeproj.config.SetBoolean('repo.dissociate', False) + self.assertFalse(fakeproj.dissociate) + + fakeproj.config.SetBoolean('repo.archive', False) + self.assertFalse(fakeproj.archive) + + fakeproj.config.SetBoolean('repo.mirror', False) + self.assertFalse(fakeproj.mirror) + + fakeproj.config.SetBoolean('repo.worktree', False) + self.assertFalse(fakeproj.use_worktree) + + fakeproj.config.SetBoolean('repo.clonebundle', False) + self.assertFalse(fakeproj.clone_bundle) + + fakeproj.config.SetBoolean('repo.submodules', False) + self.assertFalse(fakeproj.submodules) + + fakeproj.config.SetBoolean('repo.git-lfs', False) + self.assertFalse(fakeproj.git_lfs) + + fakeproj.config.SetBoolean('repo.superproject', False) + self.assertFalse(fakeproj.use_superproject) + + fakeproj.config.SetBoolean('repo.partialclone', False) + self.assertFalse(fakeproj.partial_clone) + + fakeproj.config.SetString('repo.depth', '48') + self.assertEquals(fakeproj.depth, '48') + + fakeproj.config.SetString('repo.clonefilter', 'blob:limit=10M') + self.assertEquals(fakeproj.clone_filter, 'blob:limit=10M') + + fakeproj.config.SetString('repo.partialcloneexclude', 'third_party/big_repo') + self.assertEquals(fakeproj.partial_clone_exclude, 'third_party/big_repo') + + fakeproj.config.SetString('manifest.platform', 'auto') + self.assertEquals(fakeproj.manifest_platform, 'auto') -- cgit v1.2.3-54-g00ecf