Skip to content

test: add fakeGit failure-injection knobs and cover rollback/probe failure arms - #200

Merged
andyrewlee merged 1 commit into
mainfrom
advisor/027-fakegit-failure-knobs
Sep 29, 2026
Merged

andyrewlee merged 1 commit into
mainfrom
advisor/027-fakegit-failure-knobs

Conversation

@andyrewlee

Copy link
Copy Markdown
Owner

Summary

Adds a generic failure-injection seam to fakeGit and the tests it unlocks:

  • Knobs: failErr (method-name → error), failAfter (allow N calls first — "first probe OK, second dies" windows), calls (per-method invocation counts). Guards added to every unknobbed port method; the dedicated maps (checkoutErr, rebaseErr, …) keep their call-site semantics. A comment on the struct documents the convention: every new port method gets an f.fail guard.
  • envWithSaveErr: an Env.Save hook that counts saves and fails after N — for checkpoint-save-failure windows.

New tests pin previously unreachable arms:

  • rebaseFailure's probe-error arm — a failed RebaseInProgress must surface BOTH the probe error and the original rebase error, and must not classify as ErrConflict
  • Abort: dead RebaseInProgress probe, failed RebaseAbort, and the RebaseHeadName-unreadable → pending-reparent fallback
  • AlsoFailed double-faults: create-commit + delete-rollback failure, squash-commit + restore failure, and the onto conflict → save-fail → abort-fail triple (asserts ErrConflict survives the nesting)
  • Undo save-failure ordering: env.save() precedes UpdateRefs — a failed save leaves refs provably untouched (calls["UpdateRefs"] == 0)
  • Silent-fallback visibility: repairedParentSHA's MergeBase fallback and restackAgainstTips' missing-parent RevParse fallback
  • cmd-level: runUndo on an unreadable undo.json (a directory where a file is expected) surfaces the error — loadUndo only swallows malformed JSON, not I/O errors

Test plan

  • go test ./internal/stack -count=1 — all new tests pass
  • go test ./cmd -run TestUndoPeekFailureSurfaces
  • make ci — green

@andyrewlee
andyrewlee merged commit 14dbffa into main Sep 29, 2026
3 checks passed
@andyrewlee
andyrewlee deleted the advisor/027-fakegit-failure-knobs branch September 29, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant