generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: rename comparison function; update commit finder failure messa…
…ge; update e2e test file path; extract purl type check into standalone function and add unit test Signed-off-by: Ben Selwyn-Smith <[email protected]>
- Loading branch information
Showing
5 changed files
with
106 additions
and
23 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
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
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
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
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 |
---|---|---|
|
@@ -6,11 +6,13 @@ | |
import re | ||
|
||
import hypothesis | ||
import pytest | ||
from hypothesis import given, settings | ||
from hypothesis.strategies import DataObject, data, text | ||
from packageurl import PackageURL | ||
|
||
from macaron.repo_finder import commit_finder | ||
from macaron.repo_finder.commit_finder import PurlType | ||
|
||
logger: logging.Logger = logging.getLogger(__name__) | ||
|
||
|
@@ -42,6 +44,43 @@ def _test_version(tags: list[str], name: str, version: str, target_tag: str) -> | |
assert matched_tags[0] == target_tag | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("purls", "expected"), | ||
[ | ||
pytest.param( | ||
[ | ||
"pkg:maven/apache/maven", | ||
"pkg:maven/commons-io/[email protected]", | ||
"pkg:pypi/[email protected]", | ||
"pkg:npm/@colors/[email protected]", | ||
"pkg:nuget/[email protected]", | ||
"pkg:cargo/[email protected]", | ||
], | ||
PurlType.ARTIFACT, | ||
id="Artifact PURLs", | ||
), | ||
pytest.param( | ||
[ | ||
"pkg:github/apache/maven@69bc993b8089a2d3d1ddfd6c7d4f8dc6cc205995", | ||
"pkg:github/oracle/[email protected]", | ||
"pkg:bitbucket/owner/project@tag_5", | ||
], | ||
PurlType.REPOSITORY, | ||
id="Repository PURLs", | ||
), | ||
pytest.param( | ||
["pkg:gem/[email protected]", "pkg:unknown-domain/project/owner@tag"], | ||
PurlType.UNSUPPORTED, | ||
id="Unsupported PURLs", | ||
), | ||
], | ||
) | ||
def test_abstract_purl_type(purls: list[str], expected: PurlType) -> None: | ||
"""Test each purl in list is of expected type.""" | ||
for purl in purls: | ||
assert commit_finder.abstract_purl_type(PackageURL.from_string(purl)) == expected | ||
|
||
|
||
@given(text()) | ||
@settings(max_examples=1000) | ||
def test_pattern_generation(version: str) -> None: | ||
|