|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 |
|
9 | | -from macaron.vsa.vsa import get_components_passing_policy |
| 9 | +from macaron.vsa.vsa import get_common_purl_from_artifact_purls, get_components_passing_policy |
10 | 10 |
|
11 | 11 |
|
12 | 12 | @pytest.mark.parametrize( |
@@ -192,3 +192,39 @@ def test_invalid_subject_verification_result( |
192 | 192 | ) -> None: |
193 | 193 | """Test the ``get_components_passing_policy`` in cases where the result should be ``None``.""" |
194 | 194 | assert get_components_passing_policy(policy_result) is None |
| 195 | + |
| 196 | + |
| 197 | +@pytest.mark.parametrize( |
| 198 | + ("purl_strs", "expected_purl"), |
| 199 | + [ |
| 200 | + pytest.param( |
| 201 | + [ |
| 202 | + "pkg:maven/com.fasterxml.jackson/[email protected]?type=jar", |
| 203 | + "pkg:maven/com.fasterxml.jackson/[email protected]?type=javadoc", |
| 204 | + "pkg:maven/com.fasterxml.jackson/[email protected]?type=java-source", |
| 205 | + "pkg:maven/com.fasterxml.jackson/[email protected]?type=pom", |
| 206 | + ], |
| 207 | + "pkg:maven/com.fasterxml.jackson/[email protected]", |
| 208 | + id="Common PURL exists", |
| 209 | + ), |
| 210 | + pytest.param( |
| 211 | + [ |
| 212 | + "pkg:maven/com.fasterxml.jackson/[email protected]?type=jar", |
| 213 | + "pkg:maven/com.fasterxml.jackson/[email protected]?type=jar", |
| 214 | + ], |
| 215 | + None, |
| 216 | + id="Common PURL does not exist", |
| 217 | + ), |
| 218 | + pytest.param( |
| 219 | + [], |
| 220 | + None, |
| 221 | + id="Common PURL does not exist", |
| 222 | + ), |
| 223 | + ], |
| 224 | +) |
| 225 | +def test_get_common_purl_from_artifact_purl( |
| 226 | + purl_strs: list[str], |
| 227 | + expected_purl: str | None, |
| 228 | +) -> None: |
| 229 | + """Test the ``get_common_purl_from_artifact_purls`` function.""" |
| 230 | + assert get_common_purl_from_artifact_purls(purl_strs) == expected_purl |
0 commit comments