You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[fix] Close goroutine leak in update hint + add exec cobra-level test seam (#301)
* [fix] Close goroutine leak in update hint and add exec cobra-level test seam (#287)
Finding 1: checkUpdateHint previously called u.Check(context.Background()), so
the inner HTTP goroutine kept running for up to the updater's 30s client timeout
after the outer 2s window elapsed. Fix: accept ctx context.Context as the first
param, derive context.WithTimeout(ctx, timeout) for the request, and pass tctx to
u.Check so the HTTP round-trip is bounded by both the caller's context and the
timeout. Also reset rootCmd.ctx in TestExecute's cleanup to prevent the
post-Execute cancelled signal-context from leaking into subsequent tests.
Finding 2: execCmd.RunE had no injectable constructor, so a refactor breaking
the flag-parse→filter→executor wiring could only be caught by the e2e suite.
Extract runExec(cmd, args, r git.Runner, execFn execRunner) and add buildExecCmd
mirroring the buildTrustCmd pattern (trust.go:49). Both production RunE and the
new constructor delegate to runExec, so tests exercise the real wiring. Add four
cobra-level tests: missing-target-flag, executor-invoked, JSON-output,
no-matching-worktrees.
* [fix] Address review feedback: cancel relay goroutine, unified exec flag registration, t.Fatal
- Add defer cancel() to relay goroutine in checkUpdateHint so the context
timer is released promptly on all exit paths, not just the happy path
- Extract addExecFlags() helper shared by init() and buildExecCmd() so
both flag-registration sites stay in sync and can't silently diverge
- Change t.Error to t.Fatal in cancelled-context HTTP handler assertion
* [fix] Change t.Error to t.Fatal in TestCheckUpdateHintDevVersion handler
0 commit comments