Skip to content

Commit

Permalink
Fix check_repo_exists test
Browse files Browse the repository at this point in the history
  • Loading branch information
cyclotruc committed Dec 25, 2024
1 parent fe45dbb commit cb8b203
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/gitingest/tests/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ async def test_check_repo_exists():

with patch('asyncio.create_subprocess_exec', new_callable=AsyncMock) as mock_exec:
mock_process = AsyncMock()
mock_process.communicate.return_value = (b'HTTP/1.1 200 OK\n', b'')
mock_exec.return_value = mock_process

# Test existing repository
mock_process.returncode = 0
mock_exec.return_value = mock_process
assert await check_repo_exists(url) is True

# Test non-existing repository
# Test non-existing repository (404 response)
mock_process.communicate.return_value = (b'HTTP/1.1 404 Not Found\n', b'')
mock_process.returncode = 0
assert await check_repo_exists(url) is False

# Test failed request
mock_process.returncode = 1
mock_exec.return_value = mock_process
assert await check_repo_exists(url) is False

0 comments on commit cb8b203

Please sign in to comment.