Cloner: clone() recursion support, TODO: recursion tests

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
2022-07-31 02:08:27 +02:00
parent ae34a5e95f
commit d41ead74db
3 changed files with 49 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ class MockConfig:
self.cloner_repo_url = ""
self.cloner_project_name = "Mocked Project"
self.cloner_interval = 0
self.cloner_submodules = False
class MockDirStruct:
@@ -239,7 +240,7 @@ def test_clone_from_url(tmp_path, path_repo_base):
mock = MockDirStruct(tmp_path)
mock.config.cloner_repo_url = "invalid"
c = Cloner(mock)
assert c.clone_from_url(path_repo_base.as_uri())
assert c.clone(path_repo_base.as_uri())
assert "e0c7e2a72579e24657c05e875201011d2b48bf94" == c._repo._repo.head.commit.hexsha
@@ -250,6 +251,6 @@ def test_clone_from_url_initialized(tmp_path, path_repo_base, caplog):
mock.config.cloner_repo_url = path_repo_base.as_uri()
git.Repo().init(path)
c = Cloner(mock)
assert not c.clone_from_url(path_repo_base.as_uri())
assert not c.clone(path_repo_base.as_uri())
assert caplog.records[0].levelname == "CRITICAL"
assert caplog.records[0].message == f"Repo path {path} is initialized... Refusing clone!"