This commit is contained in:
+13
-7
@@ -2,7 +2,7 @@ import base64
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from src.git import git_clone, git_pull, http_git_env, ssh_git_env
|
||||
from src.git import git_clone, git_update_mirror, http_git_env, ssh_git_env
|
||||
|
||||
|
||||
def test_ssh_git_env_uses_requested_identity_file():
|
||||
@@ -32,7 +32,7 @@ def test_http_git_env_uses_basic_auth_header_without_url_credentials():
|
||||
}
|
||||
|
||||
|
||||
def test_git_clone_passes_url_and_env_to_git(monkeypatch, tmp_path):
|
||||
def test_git_clone_uses_mirror_clone(monkeypatch, tmp_path):
|
||||
calls = []
|
||||
env = {"GIT_SSH_COMMAND": "ssh -i /tmp/test_key -o IdentitiesOnly=yes"}
|
||||
|
||||
@@ -48,13 +48,19 @@ def test_git_clone_passes_url_and_env_to_git(monkeypatch, tmp_path):
|
||||
)
|
||||
|
||||
args, cwd, actual_env = calls[0]
|
||||
assert args == ["git", "clone", "ssh://git@example.com/owner/repo.git", "."]
|
||||
assert cwd == str(tmp_path)
|
||||
assert args == [
|
||||
"git",
|
||||
"clone",
|
||||
"--mirror",
|
||||
"ssh://git@example.com/owner/repo.git",
|
||||
str(tmp_path),
|
||||
]
|
||||
assert cwd is None
|
||||
assert os.environ.items() <= actual_env.items()
|
||||
assert env.items() <= actual_env.items()
|
||||
|
||||
|
||||
def test_git_pull_passes_env_to_git(monkeypatch, tmp_path):
|
||||
def test_git_update_mirror_prunes_remote_refs(monkeypatch, tmp_path):
|
||||
calls = []
|
||||
env = {"GIT_CONFIG_COUNT": "1"}
|
||||
|
||||
@@ -63,10 +69,10 @@ def test_git_pull_passes_env_to_git(monkeypatch, tmp_path):
|
||||
|
||||
monkeypatch.setattr(subprocess, "check_call", fake_check_call)
|
||||
|
||||
assert git_pull(repository=str(tmp_path), env=env)
|
||||
assert git_update_mirror(repository=str(tmp_path), env=env)
|
||||
|
||||
args, cwd, actual_env = calls[0]
|
||||
assert args == ["git", "pull"]
|
||||
assert args == ["git", "remote", "update", "--prune"]
|
||||
assert cwd == str(tmp_path)
|
||||
assert os.environ.items() <= actual_env.items()
|
||||
assert env.items() <= actual_env.items()
|
||||
|
||||
Reference in New Issue
Block a user