chore(detector): wrap fnm GlobalNpmPrefix error; add NVM.Current tests#98
Merged
Conversation
Two cleanup-feature debris items from issue #61 that weren't already removed by #76: - internal/detector/fnm.go's GlobalNpmPrefix final error path now wraps the underlying os.Stat error with %w, matching every sibling manager's behavior (asdf, mise, n, nodenv, nvm, volta). Pre-fix the err2 was discarded. - internal/detector/nvm_test.go gains three tests for NVM.Current() to close the only Current() method in the package that had no method-level test coverage: - TestNVMCurrent_InvokesShell: pins the production script shape (sources nvm.sh, runs `nvm current`, parses output). - TestNVMCurrent_PropagatesShellError: pins the wrapped-error contract (%w wrap of runScript failures). - TestNVMCurrent_SystemIsError: pins the end-to-end "system" handling (nvm current printing "system" surfaces an error). Items #1 (cleanup.go confirm := true / _ = confirm) and #2 (upgrade.go _ = yes) from the issue body were already cleaned up by PR #95 / #76. Closes #61
|
✔️ 6db4199 - Conventional commits check succeeded. |
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
Bundles the two remaining cleanup-feature debris items from issue
#61. Two of the four items called out in the issue body were
already removed by PR #95 / issue #76 —
cleanup.go'sconfirm := true/_ = confirmdead lines andupgrade.go's_ = yesline — so this PR focuses on the items still standing:internal/detector/fnm.go'sGlobalNpmPrefixfinal error pathnow wraps the underlying
os.Staterror with%w. Thepre-fix line discarded
err2entirely:Every sibling implementation (asdf, mise, n, nodenv, nvm, volta)
correctly uses
%win the equivalent function. Low-severityconsistency fix.
NVM.Current()now has full method-level test coverage.internal/detector/nvm_test.gopreviously only exercised thepure output parser
parseNVMCurrent, but notNVM.Current()itself — every other manager's
Current()has aTest<X>Current_InvokesShell-style test (fnm, asdf, mise,nodenv, volta). Three new tests close the gap:
TestNVMCurrent_InvokesShell— pins the production scriptshape (sources nvm.sh, runs
nvm current, parses output).TestNVMCurrent_PropagatesShellError— pins the wrapped-error contract (
runScriptfailure surfaces with%w).TestNVMCurrent_SystemIsError— pins the end-to-end "system"handling (
nvm currentprinting "system" surfaces an error,not just at the parse layer).
Linked issues
Closes #61
Type of change
chore— maintenance / dependency bumpfeat— new feature (MINOR bump)fix— bug fix (PATCH bump)refactor— no behavior changeperf— performance improvementtest— tests onlydocs— documentation onlyci— CI/CD onlybuild— build system onlyChecklist
chore(scope): subject)make cilocally and it passes (golangci-lint run,go vet,go test -race ./...all green; detectorcoverage rose from 76.8% → 77.5%)
NVM.Current();GlobalNpmPrefixis exercised by theexisting
TestFNM_*matrix)CHANGELOG.mdgets a
### Fixedentry under[Unreleased])make lintgreen)and updated CHANGELOG.md
Notes
Items #1 (
confirm := true/_ = confirm) and #2 (_ = yes)from issue #61's body were already fixed by PR #95 / issue #76
when that PR restructured the per-version prompt loop. Those
removals are noted in the PR body / CHANGELOG entry but no
new code touches them in this branch.
Files touched
internal/detector/fnm.go—GlobalNpmPrefix's final errorpath wraps the discarded
err2with%w.internal/detector/nvm_test.go— adds three tests forNVM.Current(): invocation, error propagation, and theend-to-end "system" branch.
CHANGELOG.md—### Fixedentry under[Unreleased]documenting the wrap and test additions with chore(cleanup): dead code + fnm error-wrapping + nvm Current() test gap from cleanup-feature PR #61 reference.