forked from TracecatHQ/tracecat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(internal): GitHub parse polynomial regex
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,3 +104,35 @@ async def test_registry_async_function_can_be_called(mock_package): | |
udf = repo.get("test.async_test_function") | ||
for i in range(10): | ||
assert await udf.fn(num=i) == i | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url,expected", | ||
[ | ||
("git+ssh://[email protected]/org/repo", ("org", "repo", "main")), | ||
("git+ssh://[email protected]/org/repo.git", ("org", "repo", "main")), | ||
("git+ssh://[email protected]/org/repo@branch", ("org", "repo", "branch")), | ||
("git+ssh://[email protected]/org/repo.git@branch", ("org", "repo", "branch")), | ||
], | ||
) | ||
def test_parse_github_url_valid(url: str, expected: tuple[str, str, str]): | ||
"""Test that valid GitHub URLs are correctly parsed.""" | ||
from tracecat.registry.repository import parse_github_url | ||
|
||
assert parse_github_url(url) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"invalid_url", | ||
[ | ||
"https://github.com/org/repo", | ||
"git+ssh://[email protected]/org", | ||
"git+ssh://[email protected]/org/repo@branch/extra", | ||
], | ||
) | ||
def test_parse_github_url_invalid(invalid_url: str): | ||
"""Test that invalid GitHub URLs raise ValueError.""" | ||
from tracecat.registry.repository import parse_github_url | ||
|
||
with pytest.raises(ValueError): | ||
parse_github_url(invalid_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters