Repository navigation
test: add fakeGit failure-injection knobs and cover rollback/probe failure arms - #200
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a generic failure-injection seam to
fakeGitand the tests it unlocks: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 anf.failguard.envWithSaveErr: anEnv.Savehook that counts saves and fails after N — for checkpoint-save-failure windows.New tests pin previously unreachable arms:
rebaseFailure's probe-error arm — a failedRebaseInProgressmust surface BOTH the probe error and the original rebase error, and must not classify asErrConflictAbort: deadRebaseInProgressprobe, failedRebaseAbort, and theRebaseHeadName-unreadable → pending-reparent fallbackAlsoFaileddouble-faults: create-commit + delete-rollback failure, squash-commit + restore failure, and the onto conflict → save-fail → abort-fail triple (assertsErrConflictsurvives the nesting)Undosave-failure ordering:env.save()precedesUpdateRefs— a failed save leaves refs provably untouched (calls["UpdateRefs"] == 0)repairedParentSHA'sMergeBasefallback andrestackAgainstTips' missing-parentRevParsefallbackrunUndoon an unreadableundo.json(a directory where a file is expected) surfaces the error —loadUndoonly swallows malformed JSON, not I/O errorsTest plan
go test ./internal/stack -count=1— all new tests passgo test ./cmd -run TestUndoPeekFailureSurfacesmake ci— green