Skip to content

Commit c004390

Browse files
mikolalysenkoclaude
andcommitted
Update repair output tests for kept originals
The human repair output tests assumed repair sweeps the active patch's beforeHash blob. It now keeps it (#893), so the no-orphan case checks both blobs in use and the orphan case removes only the orphan. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent a6605b1 commit c004390

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -314,40 +314,36 @@ fn scan_non_json_no_packages_prints_friendly_message() {
314314
fn repair_non_json_no_orphans_prints_summary() {
315315
let tmp = tempfile::tempdir().unwrap();
316316
write_manifest(tmp.path(), "pkg:npm/repair-target@1.0.0", b"a", b"b");
317-
// `write_manifest` writes BOTH the beforeHash and afterHash blobs, but
318-
// repair treats `beforeHash` blobs as unused-by-design (they are fetched
319-
// on demand during rollback). To exercise the genuine "all in use" path
320-
// implied by this test's name, drop the beforeHash blob so the only
321-
// remaining blob is the in-use afterHash one.
317+
// `write_manifest` writes BOTH the beforeHash and afterHash blobs of
318+
// the active patch, and repair keeps both (#893: the beforeHash blob is
319+
// an offline rollback's only restore data).
322320
let blobs = tmp.path().join(".socket/blobs");
323321
let before_blob = blobs.join(git_sha256(b"a"));
324322
let after_blob = blobs.join(git_sha256(b"b"));
325-
std::fs::remove_file(&before_blob).unwrap();
326323
assert!(
327-
after_blob.exists(),
328-
"fixture precondition: afterHash blob present"
324+
before_blob.exists() && after_blob.exists(),
325+
"fixture precondition: both blobs present"
329326
);
330327

331328
let (code, stdout, _stderr) = common::run_with_env(tmp.path(), &["repair", "--offline"], &[]);
332329
assert_eq!(code, 0);
333-
// With exactly one in-use blob and no orphans, repair must report the
330+
// With two in-use blobs and no orphans, repair must report the
334331
// all-in-use status (not a removal) and finish. The old check accepted
335332
// any output containing "Repair complete.", so a repair that wrongly
336333
// deleted the in-use blob — or skipped the cleanup scan entirely — still
337334
// passed.
338335
assert!(
339-
stdout.contains("Checked 1 blob: in use."),
340-
"no-orphan repair must report the single blob as in-use; got: {stdout}"
336+
stdout.contains("Checked 2 blobs: all in use."),
337+
"no-orphan repair must report both blobs as in use; got: {stdout}"
341338
);
342339
assert!(
343340
stdout.contains("Repair complete."),
344341
"non-JSON repair should print the completion summary; got: {stdout}"
345342
);
346-
// Critically: the in-use afterHash blob (the patched file content that
347-
// `apply` needs) must NOT be deleted by repair.
343+
// Critically: neither in-use blob may be deleted by repair.
348344
assert!(
349-
after_blob.exists(),
350-
"repair must preserve the in-use afterHash blob"
345+
after_blob.exists() && before_blob.exists(),
346+
"repair must preserve the active patch's afterHash and beforeHash blobs"
351347
);
352348
}
353349

@@ -370,12 +366,16 @@ fn repair_non_json_with_orphans_prints_cleanup_summary() {
370366
assert_eq!(code, 0);
371367
// The test name promises a *cleanup* summary, so assert the cleanup
372368
// actually happened — both in the printed summary and on disk. Pin the
373-
// exact count (the orphan blob + the by-design-unused beforeHash blob =
374-
// 2) so a repair that removes too few OR too many blobs fails here; the
375-
// old `contains("Removed")` accepted any nonzero count.
369+
// exact count (only the orphan: the active patch's beforeHash blob is
370+
// kept, #893) so a repair that removes too few OR too many blobs fails
371+
// here; the old `contains("Removed")` accepted any nonzero count.
372+
assert!(
373+
stdout.contains("Removed 1 unused blob ("),
374+
"repair with orphans must report exactly 1 removed unused blob; got: {stdout}"
375+
);
376376
assert!(
377-
stdout.contains("Removed 2 unused blobs"),
378-
"repair with orphans must report exactly 2 removed unused blobs; got: {stdout}"
377+
blobs.join(git_sha256(b"a")).exists(),
378+
"repair must keep the active patch's beforeHash blob"
379379
);
380380
assert!(
381381
!orphan.exists(),

0 commit comments

Comments
 (0)