Skip to content

Commit 9568eae

Browse files
committed
test(crawlers): fix python METADATA blank-line break test
The earlier fixture set BOTH Name and Version before reaching the blank line, so the function broke via the both-set guard at L71-72 instead of the blank-line break at L80-81. Replace with a fixture where only Name is set when the blank line is hit — that forces the L80-81 path and verifies the function correctly returns None when the trailer is interrupted before Version is read. Assisted-by: Claude Code:claude-opus-4-7
1 parent f1b0474 commit 9568eae

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

crates/socket-patch-core/tests/crawler_python_e2e.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,26 +438,28 @@ async fn get_site_packages_paths_with_global_prefix_passthrough() {
438438

439439
/// METADATA with extra header lines AFTER the blank line should NOT be
440440
/// parsed — the parser must stop at the first blank line after
441-
/// collecting name+version. Covers `python_crawler.rs:80-81`.
441+
/// collecting name+version. Covers `python_crawler.rs:80-81` (the
442+
/// blank-line break path that fires before both fields are set).
442443
#[tokio::test]
443444
async fn read_python_metadata_stops_at_blank_line_after_headers() {
444445
let tmp = tempfile::tempdir().unwrap();
445446
let dist = tmp.path().join("requests-2.28.0.dist-info");
446447
tokio::fs::create_dir(&dist).await.unwrap();
447-
// Headers block, then blank line, then garbage that would otherwise
448-
// (re-)set Name to something else — the parser must NOT pick it up.
448+
// Only `Name` is set when we hit the blank line — version is still
449+
// None, so the early both-set break (L71-72) does NOT fire. Instead
450+
// we must take the blank-line break at L80-81. After break, the
451+
// final-match arm returns None because version was never set.
449452
tokio::fs::write(
450453
dist.join("METADATA"),
451-
"Name: requests\nVersion: 2.28.0\n\nName: would-be-overwritten\nVersion: 9.9.9\n",
454+
"Name: requests\n\nVersion: 2.28.0\n",
452455
)
453456
.await
454457
.unwrap();
455458

456459
let result = read_python_metadata(&dist).await;
457460
assert_eq!(
458-
result,
459-
Some(("requests".to_string(), "2.28.0".to_string())),
460-
"parser must stop at first blank line; got {result:?}"
461+
result, None,
462+
"blank-line break must fire before Version is read; got {result:?}"
461463
);
462464
}
463465

0 commit comments

Comments
 (0)