|
18 | 18 | decide_version_combinations, |
19 | 19 | fetch_supported_nodejs_versions, |
20 | 20 | find_new_or_updated, |
| 21 | + latest_tag_key, |
21 | 22 | load_build_contexts, |
22 | 23 | scrape_supported_python_versions, |
23 | 24 | ) |
@@ -289,3 +290,59 @@ def test_find_new_or_updated_with_digest() -> None: |
289 | 290 | res = find_new_or_updated([new], {existing.key: existing}) |
290 | 291 |
|
291 | 292 | assert len(res) == 0 |
| 293 | + |
| 294 | + |
| 295 | +def test_latest_tag_key_matches_latest_sources() -> None: |
| 296 | + versions = [ |
| 297 | + BuildVersion( |
| 298 | + key="python3.14-nodejs25", |
| 299 | + python="3.14", |
| 300 | + python_canonical="3.14.3", |
| 301 | + python_image="3.14.3-trixie", |
| 302 | + nodejs="25", |
| 303 | + nodejs_canonical="25.8.1", |
| 304 | + distro="trixie", |
| 305 | + platforms=["linux/amd64", "linux/arm64"], |
| 306 | + ), |
| 307 | + BuildVersion( |
| 308 | + key="python3.14-nodejs24-bookworm", |
| 309 | + python="3.14", |
| 310 | + python_canonical="3.14.3", |
| 311 | + python_image="3.14.3-bookworm", |
| 312 | + nodejs="24", |
| 313 | + nodejs_canonical="24.14.0", |
| 314 | + distro="bookworm", |
| 315 | + platforms=["linux/amd64", "linux/arm64"], |
| 316 | + ), |
| 317 | + ] |
| 318 | + |
| 319 | + with ( |
| 320 | + mock.patch("docker_python_nodejs.versions._latest_python_minor", return_value="3.14"), |
| 321 | + mock.patch("docker_python_nodejs.versions.fetch_latest_nodejs_version", return_value="v25.8.1"), |
| 322 | + ): |
| 323 | + assert latest_tag_key(versions) == "python3.14-nodejs25" |
| 324 | + |
| 325 | + |
| 326 | +def test_latest_tag_key_fails_if_canonical_build_is_missing() -> None: |
| 327 | + versions = [ |
| 328 | + BuildVersion( |
| 329 | + key="python3.14-nodejs24", |
| 330 | + python="3.14", |
| 331 | + python_canonical="3.14.3", |
| 332 | + python_image="3.14.3-trixie", |
| 333 | + nodejs="24", |
| 334 | + nodejs_canonical="24.14.0", |
| 335 | + distro="trixie", |
| 336 | + platforms=["linux/amd64", "linux/arm64"], |
| 337 | + ), |
| 338 | + ] |
| 339 | + |
| 340 | + with ( |
| 341 | + mock.patch("docker_python_nodejs.versions._latest_python_minor", return_value="3.14"), |
| 342 | + mock.patch("docker_python_nodejs.versions.fetch_latest_nodejs_version", return_value="v25.8.1"), |
| 343 | + pytest.raises( |
| 344 | + ValueError, |
| 345 | + match=r"Computed latest tag 'python3\.14-nodejs25' was not part of the current build set", |
| 346 | + ), |
| 347 | + ): |
| 348 | + latest_tag_key(versions) |
0 commit comments