Skip to content

test: add real-git e2e coverage for failure paths and undo discovery - #201

Merged
andyrewlee merged 1 commit into
mainfrom
advisor/028-e2e-failure-paths
Sep 29, 2026
Merged

andyrewlee merged 1 commit into
mainfrom
advisor/028-e2e-failure-paths

Conversation

@andyrewlee

Copy link
Copy Markdown
Owner

Plan 028 — Real-git failure-path integration tests

Adds the e2e coverage the fake-Git suite can't express:

  • TestCreateWorktreeMaterializeFailure — pre-obstructs the canonical
    ~/.stacked/worktrees/<repo-key>/feat-x path with a non-empty dir so
    git worktree add fails after the branch is tracked. Asserts exit 1 with
    the st worktree retry hint, branch still tracked, no worktree registered;
    then removes the obstruction, retries st worktree feat-x, and runs
    st undo — exercising the LinkedOwnerOf discovery arm because the journal
    never recorded createdWorktrees. Sibling worktree verified untouched.
  • TestSubmitInvalidRefCleanError — --remote=-x dies cleanly at the
    remote-exists check; a corrupt-state.json branch named -bad reaches
    validRefArg inside PushBranches, pinning the nil-result arm: exit 1,
    wrapped message, generic error JSON code — no panic/internal envelope.
  • TestWorktreeRemoveAllLeavesUntracked — a manually-added worktree for an
    untracked scratch branch survives st worktree rm --all on disk and in
    git worktree list; JSON removed/skipped only name tracked branches.
  • TestUndoUnreadableJournal — undo.json replaced by a directory →
    exit 1, state.json byte-identical.

Verification

  • Focused: go test ./e2e -run 'TestCreateWorktreeMaterializeFailure|TestSubmitInvalidRefCleanError|TestWorktreeRemoveAllLeavesUntracked|TestUndoUnreadableJournal' -v — 4/4 pass
  • make ci — clean (fmt + lint + vet + cross-vet + race + e2e), merged coverage 87.6%
  • No plans/ content on this branch; test-only diff.

Plan 028. Close the gap between fakeGit failure injection and real
subprocess behavior:

- create --worktree with the canonical worktree path pre-obstructed:
  exits 1 naming the st worktree retry, keeps the branch tracked, and
  after a manual st worktree retry st undo removes the worktree via
  LinkedOwnerOf discovery (the journal never got createdWorktrees).
- st submit with a corrupt-state invalid refname surfaces a clean
  exit-1 wrapped error (text and --json envelope), not a panic.
- st worktree rm --all removes tracked-branch worktrees but leaves a
  manually-created worktree for an untracked branch on disk and in
  git's registry; the JSON skipped list only names tracked branches.
- st undo with an unreadable undo.json exits non-zero with state.json
  byte-identical.
@andyrewlee
andyrewlee merged commit 27913b0 into main Sep 29, 2026
3 checks passed
@andyrewlee
andyrewlee deleted the advisor/028-e2e-failure-paths branch September 29, 2026 01:02
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