Skip to content

Commit 113c017

Browse files
committed
Expect a total rollback failure where nothing reached the end state
This PR makes rollback report status "error" (code rollback_failed) when something failed and nothing was rolled back, already original or not installed. Two tests still expected partial_failure for that case: - e2e_bun_lockb's shared refused-binary-pin helper: the takeover caller sees alreadyOriginal 1 (partial_failure), but the alias/transitive caller sees 0, a total failure. Derive the expected status from alreadyOriginal. - apply/bun_global_store rollback_refuses_bun_global_store_packages (from #1009, arrived via the main merge): every package is refused, so it is a total failure now. Also merges origin/main. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2990e48 commit 113c017

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎crates/socket-patch-cli/tests/apply/bun_global_store.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ fn rollback_refuses_bun_global_store_packages() {
188188
);
189189

190190
let v = run(&proj, "rollback");
191-
assert_eq!(v["status"], "partial_failure", "{v}");
191+
// Every package is refused and none reached the unpatched end state, so
192+
// the run is a total failure.
193+
assert_eq!(v["status"], "error", "{v}");
194+
assert_eq!(v["error"]["code"], "rollback_failed", "{v}");
192195
assert_refused(&v, "pkg:npm/left-pad@1.3.0");
193196
assert_refused(&v, "pkg:npm/is-number@6.0.0");
194197
assert_eq!(std::fs::read(left_pad.join("index.js")).unwrap(), AFTER);

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,15 @@ fn rollback_refuses_binary_hosted_pin_then_checkout(fixture: &Fixture, server: &
130130
&["rollback", "--yes", "--patch-server-url", &uri],
131131
);
132132
assert_eq!(code, 1, "a binary hosted pin cannot be restored: {env}");
133-
// The refused pin counts as a failure (#1066), but the installed copy is
134-
// already original, so the run is a partial failure, not a total one.
135-
assert_eq!(env["status"], "partial_failure", "{env}");
133+
// The refused pin counts as a failure (#1066). When the installed copy
134+
// is already original the run is a partial failure; when nothing reached
135+
// the unpatched end state it is a total failure (`error`).
136+
if env["alreadyOriginal"].as_u64().unwrap_or(0) > 0 {
137+
assert_eq!(env["status"], "partial_failure", "{env}");
138+
} else {
139+
assert_eq!(env["status"], "error", "{env}");
140+
assert_eq!(env["error"]["code"], "rollback_failed", "{env}");
141+
}
136142
assert_eq!(env["failed"], 1, "{env}");
137143
let failed = env["hosted"]["failed"]
138144
.as_array()

0 commit comments

Comments
 (0)