Skip to content

Commit b3a75fb

Browse files
committed
Align #1105 test with the hosted-pin eject
Merging main brought in #1713's regression test, which expects plain `vendor` over a hosted pin at patch A to vendor the manifest's newer patch B. This branch makes plain `vendor` eject the hosted pins from the lockfiles instead (manifest unread), so the merged tree failed the test deterministically and the PR was evicted from the merge queue twice (coverage (1), runs 40572480618 and 40575886984). Keep the #1105 setup (venv synced from the hosted lock, manifest at B) and assert the eject outcome: exit 0, no package_not_installed, the project vendored at A with the hosted URL gone and B unread. The superseded-install rule behind `scan --mode vendored` keeps its unit test, hosted_pin_marks_a_pypi_install_superseded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQeQBzNvTuMrf6bWCp
1 parent 6d336be commit b3a75fb

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

‎crates/socket-patch-cli/tests/mode_migration_pypi.rs‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,14 +1030,15 @@ async fn poetry_revendors_to_a_superseding_patch_over_a_patched_venv() {
10301030

10311031
/// #1105: a project hosted at patch A whose venv was then synced from the
10321032
/// hosted lock (`uv sync`, `poetry install`, `uv pip install -r`), so six
1033-
/// holds A's patched bytes, moves to vendored at the superseding patch B.
1034-
/// The installed copy matches neither the pristine release nor B's
1035-
/// output; it used to be dropped as `package_not_installed` (exit 1, the
1036-
/// project left hosted on A) while `scan --mode vendored --dry-run`
1037-
/// previewed success. The takeover must restore the upstream entry and
1038-
/// vendor B.
1039-
#[tokio::test]
1040-
async fn hosted_to_vendored_takes_a_superseding_patch_over_a_hosted_venv() {
1033+
/// holds A's patched bytes, while the agent manifest already names the
1034+
/// superseding patch B. Plain `vendor` used to drop the package as
1035+
/// `package_not_installed` (exit 1, the project left hosted on A). It now
1036+
/// ejects the hosted pin: A's record comes from the API, never the
1037+
/// manifest or the venv, and the project ends up vendored at A.
1038+
/// (`scan --mode vendored` is how to move to B; the superseded-install
1039+
/// rule it relies on is covered by `hosted_pin_marks_a_pypi_install_superseded`.)
1040+
#[tokio::test]
1041+
async fn hosted_to_vendored_ejects_the_hosted_pin_over_a_hosted_venv() {
10411042
let lanes: [(&str, StageFn); 3] = [
10421043
("uv", stage_uv_with_sibling),
10431044
("poetry", stage_poetry),
@@ -1059,19 +1060,24 @@ async fn hosted_to_vendored_takes_a_superseding_patch_over_a_hosted_venv() {
10591060

10601061
let venv = root.join("../hosted-venv");
10611062
venv_installed_from_patch_a(&venv);
1062-
stage_manifest_with(&root, UUID_B, PATCHED_B);
1063+
// Serve A's prebuilt artifact and record, then point the manifest
1064+
// at B: the eject must not read it.
1065+
stage_manifest(&root);
10631066
prebuilt_common::mount_project(&server, &root).await;
1067+
mount_patch_view(&server).await;
1068+
stage_manifest_with(&root, UUID_B, PATCHED_B);
10641069
mount_pypi_json(&server).await;
10651070
let uri = server.uri();
10661071
let pypi = format!("{uri}/pypi");
10671072
let extra = [
10681073
("VIRTUAL_ENV", venv.to_str().unwrap()),
10691074
("SOCKET_PYPI_JSON_API", pypi.as_str()),
10701075
];
1071-
let args = ["vendor", "--patch-server-url", &uri, "--vendor-url", &uri];
1076+
let mut args = vec!["vendor", "--patch-server-url", &uri, "--vendor-url", &uri];
1077+
args.extend(api_args(&uri));
10721078

10731079
let (code, env) = run_cli(&root, &args, &extra);
1074-
assert_eq!(code, 0, "{lane}: takeover onto B: {env:#}");
1080+
assert_eq!(code, 0, "{lane}: eject of hosted A: {env:#}");
10751081
assert!(
10761082
!env.to_string().contains("package_not_installed"),
10771083
"{lane}: the installed copy is not reported missing: {env:#}"
@@ -1081,10 +1087,10 @@ async fn hosted_to_vendored_takes_a_superseding_patch_over_a_hosted_venv() {
10811087
.map(|f| std::fs::read_to_string(root.join(f)).unwrap())
10821088
.collect();
10831089
assert!(
1084-
wired.contains(&format!(".socket/vendor/pypi/{UUID_B}/"))
1090+
wired.contains(&format!(".socket/vendor/pypi/{UUID}/"))
10851091
&& !wired.contains(&hosted_url)
1086-
&& !wired.contains(UUID),
1087-
"{lane}: wired to vendored B, hosted A gone:\n{wired}"
1092+
&& !wired.contains(UUID_B),
1093+
"{lane}: wired to vendored A, hosted A gone, manifest B unread:\n{wired}"
10881094
);
10891095
}
10901096
}

0 commit comments

Comments
 (0)