Remove end-to-end test for git backup push
This commit is contained in:
parent
727057439e
commit
8805da33b6
2 changed files with 3 additions and 113 deletions
|
|
@ -304,103 +304,6 @@ def test_commit_state_change_no_push_when_remote_unset(monkeypatch: pytest.Monke
|
|||
assert not push_calls, "git push should NOT be called when GIT_BACKUP_REMOTE is not set"
|
||||
|
||||
|
||||
@pytest.mark.real_git_backup_push
|
||||
@SKIP_IF_NO_GIT
|
||||
def test_commit_state_change_e2e_push_to_bare_repo(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
||||
"""End-to-end test: commit_state_change pushes to a real bare git repository."""
|
||||
git_executable: str | None = shutil.which("git")
|
||||
assert git_executable is not None, "git executable not found"
|
||||
|
||||
# Create a bare remote repository
|
||||
bare_repo_path: Path = tmp_path / "remote.git"
|
||||
subprocess.run([git_executable, "init", "--bare", str(bare_repo_path)], check=True, capture_output=True) # noqa: S603
|
||||
|
||||
# Configure backup with remote pointing to bare repo
|
||||
backup_path: Path = tmp_path / "backup"
|
||||
monkeypatch.setenv("GIT_BACKUP_PATH", str(backup_path))
|
||||
monkeypatch.setenv("GIT_BACKUP_REMOTE", str(bare_repo_path))
|
||||
|
||||
# Create mock reader with some state
|
||||
mock_reader = MagicMock()
|
||||
feed1 = MagicMock()
|
||||
feed1.url = "https://example.com/feed.rss"
|
||||
mock_reader.get_feeds.return_value = [feed1]
|
||||
|
||||
def get_tag_side_effect(
|
||||
feed_or_key: tuple | str,
|
||||
tag: str | None = None,
|
||||
default: str | None = None,
|
||||
) -> list[Any] | str | None:
|
||||
if feed_or_key == ():
|
||||
return []
|
||||
if tag == "webhook":
|
||||
return "https://discord.com/api/webhooks/123/abc"
|
||||
return default
|
||||
|
||||
mock_reader.get_tag.side_effect = get_tag_side_effect
|
||||
|
||||
# Perform backup with commit and push
|
||||
commit_state_change(mock_reader, "Initial backup")
|
||||
|
||||
# Verify commit exists in local backup repo
|
||||
result: subprocess.CompletedProcess[str] = subprocess.run( # noqa: S603
|
||||
[git_executable, "-C", str(backup_path), "log", "--oneline"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
assert "Initial backup" in result.stdout
|
||||
|
||||
# Verify origin remote is configured correctly
|
||||
result = subprocess.run( # noqa: S603
|
||||
[git_executable, "-C", str(backup_path), "remote", "get-url", "origin"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
assert result.stdout.strip() == str(bare_repo_path)
|
||||
|
||||
# Verify commit was pushed to the bare remote
|
||||
result = subprocess.run( # noqa: S603
|
||||
[git_executable, "-C", str(bare_repo_path), "log", "--oneline", "master"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
assert "Initial backup" in result.stdout
|
||||
|
||||
# Verify state.json content in the remote
|
||||
result = subprocess.run( # noqa: S603
|
||||
[git_executable, "-C", str(bare_repo_path), "show", "master:state.json"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
state_data: dict[str, Any] = json.loads(result.stdout)
|
||||
assert state_data["feeds"][0]["url"] == "https://example.com/feed.rss"
|
||||
assert state_data["feeds"][0]["webhook"] == "https://discord.com/api/webhooks/123/abc"
|
||||
|
||||
# Perform a second backup to verify subsequent pushes work
|
||||
feed2 = MagicMock()
|
||||
feed2.url = "https://another.com/feed.xml"
|
||||
mock_reader.get_feeds.return_value = [feed1, feed2]
|
||||
|
||||
commit_state_change(mock_reader, "Add second feed")
|
||||
|
||||
# Verify both commits are in the remote
|
||||
result = subprocess.run( # noqa: S603
|
||||
[git_executable, "-C", str(bare_repo_path), "log", "--oneline", "master"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
assert "Initial backup" in result.stdout
|
||||
assert "Add second feed" in result.stdout
|
||||
|
||||
|
||||
# Integration tests for embed-related endpoint backups
|
||||
|
||||
|
||||
client: TestClient = TestClient(app)
|
||||
test_webhook_name: str = "Test Backup Webhook"
|
||||
test_webhook_url: str = "https://discord.com/api/webhooks/999999999/testbackupwebhook"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue