Spaces:
Sleeping
Sleeping
File size: 1,150 Bytes
3fe77a3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | """Tests for CLI functionality."""
import pytest
from typer import BadParameter
from cli.main import validate_github_url
def test_validate_github_url_valid():
"""Test valid GitHub URL validation."""
url = "https://github.com/owner/repo/issues/123"
owner, repo, issue_num = validate_github_url(url)
assert owner == "owner"
assert repo == "repo"
assert issue_num == 123
def test_validate_github_url_invalid():
"""Test invalid GitHub URL validation."""
invalid_urls = [
"https://github.com/owner/repo",
"https://gitlab.com/owner/repo/issues/123",
"not a url",
"https://github.com/owner/repo/pull/123",
]
for url in invalid_urls:
with pytest.raises(BadParameter):
validate_github_url(url)
def test_validate_github_url_with_different_numbers():
"""Test URL validation with different issue numbers."""
url = "https://github.com/test/project/issues/9999"
owner, repo, issue_num = validate_github_url(url)
assert owner == "test"
assert repo == "project"
assert issue_num == 9999
|