Skip to content

Commit 7e3f800

Browse files
Merge branch 'main' into fix/branch_name
2 parents 97ab6c3 + 0e74d67 commit 7e3f800

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

src/gitingest/query_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"bitbucket.org",
2323
"gitea.com",
2424
"codeberg.org",
25+
"gitingest.com",
2526
]
2627

2728

tests/query_parser/test_query_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ async def test_parse_url_valid_https() -> None:
1818
"https://github.com/user/repo",
1919
"https://gitlab.com/user/repo",
2020
"https://bitbucket.org/user/repo",
21+
"https://gitea.com/user/repo",
22+
"https://codeberg.org/user/repo",
23+
"https://gitingest.com/user/repo",
2124
]
2225
for url in test_cases:
2326
result = await _parse_repo_source(url)
@@ -35,6 +38,9 @@ async def test_parse_url_valid_http() -> None:
3538
"http://github.com/user/repo",
3639
"http://gitlab.com/user/repo",
3740
"http://bitbucket.org/user/repo",
41+
"http://gitea.com/user/repo",
42+
"http://codeberg.org/user/repo",
43+
"http://gitingest.com/user/repo",
3844
]
3945
for url in test_cases:
4046
result = await _parse_repo_source(url)

tests/test_query_ingestion.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any
55
from unittest.mock import patch
66

7-
from gitingest.query_ingestion import _extract_files_content, _read_file_content, _scan_directory
7+
from gitingest.query_ingestion import _extract_files_content, _read_file_content, _scan_directory, run_ingest_query
88

99

1010
def test_scan_directory(temp_directory: Path, sample_query: dict[str, Any]) -> None:
@@ -153,6 +153,28 @@ def test_include_src_wildcard_prefix(temp_directory: Path, sample_query: dict[st
153153
assert file_paths == expected_paths, "Missing or unexpected files in result"
154154

155155

156+
def test_run_ingest_query(temp_directory: Path, sample_query: dict[str, Any]) -> None:
157+
"""
158+
Test the run_ingest_query function to ensure it processes the directory correctly.
159+
"""
160+
sample_query["local_path"] = temp_directory
161+
sample_query["subpath"] = "/"
162+
sample_query["type"] = None
163+
164+
summary, _, content = run_ingest_query(sample_query)
165+
166+
assert "Repository: test_user/test_repo" in summary
167+
assert "Files analyzed: 8" in summary
168+
assert "src/subfile1.txt" in content
169+
assert "src/subfile2.py" in content
170+
assert "src/subdir/file_subdir.txt" in content
171+
assert "src/subdir/file_subdir.py" in content
172+
assert "file1.txt" in content
173+
assert "file2.py" in content
174+
assert "dir1/file_dir1.txt" in content
175+
assert "dir2/file_dir2.txt" in content
176+
177+
156178
# multiple patterns
157179
# TODO: test with multiple include patterns: ['*.txt', '*.py']
158180
# TODO: test with multiple include patterns: ['/src/*', '*.txt']

tests/test_repository_clone.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
""" Tests for the repository_clone module. """
22

3+
import asyncio
34
from unittest.mock import AsyncMock, patch
45

56
import pytest
67

8+
from gitingest.exceptions import AsyncTimeoutError
79
from gitingest.repository_clone import CloneConfig, _check_repo_exists, clone_repo
810

911

@@ -233,3 +235,18 @@ async def test_check_repo_exists_with_permanent_redirect() -> None:
233235
mock_exec.return_value = mock_process
234236

235237
assert await _check_repo_exists(url)
238+
239+
240+
@pytest.mark.asyncio
241+
async def test_clone_repo_with_timeout() -> None:
242+
"""
243+
Test the `clone_repo` function when the cloning process exceeds the timeout limit.
244+
Verifies that an AsyncTimeoutError is raised.
245+
"""
246+
clone_config = CloneConfig(url="https://github.com/user/repo", local_path="/tmp/repo")
247+
248+
with patch("gitingest.repository_clone._check_repo_exists", return_value=True):
249+
with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec:
250+
mock_exec.side_effect = asyncio.TimeoutError
251+
with pytest.raises(AsyncTimeoutError, match="Operation timed out after"):
252+
await clone_repo(clone_config)

0 commit comments

Comments
 (0)