Skip to content

test(errors): cover Wrap/Multi/Join/Is* and category inference (100%)#127

Open
abhicris wants to merge 1 commit into
luxfi:mainfrom
abhicris:test/2026-06-01-errors-pkg-coverage
Open

test(errors): cover Wrap/Multi/Join/Is* and category inference (100%)#127
abhicris wants to merge 1 commit into
luxfi:mainfrom
abhicris:test/2026-06-01-errors-pkg-coverage

Conversation

@abhicris
Copy link
Copy Markdown

@abhicris abhicris commented Jun 1, 2026

Summary

The github.com/luxfi/node/errors package shipped with zero tests despite being a public utility surface (sentinel errors, WrappedError context chain, Multi/Join aggregation, retry helpers like IsTemporary/IsPermanent). This adds 22 tests that bring the package to 100.0% statement coverage.

What is covered

  • WrappedError.Error() format — with and without an explicit message
  • Wrap / WrapWithContext nil pass-through; context map preservation; allocated-and-writable context on the bare Wrap path
  • errors.Is / errors.As chain through Wrap (including double-wrap)
  • IsNotFound, IsClosed, IsTimeout direct + %w wrapping
  • IsTemporary against both the sentinel set and the optional Temporary() bool interface
  • IsPermanent across every permanent sentinel + fmt.Errorf %w chains
  • GetCategory: wrapped category, sentinel inference, unknown fallback, and the precedence rule (wrapped category beats inferred)
  • Multi.Error / Add / Err at sizes 0, 1, and N; nil-add ignored
  • Join nil pass-through and multi-error combination

Verification

$ go test ./errors/... -count=1 -v
... 22 PASS ...
PASS
ok  	github.com/luxfi/node/errors	0.008s

$ go test ./errors/... -race -count=1
ok  	github.com/luxfi/node/errors	1.020s

$ go test ./errors/... -cover
ok  	github.com/luxfi/node/errors	0.011s	coverage: 100.0% of statements

$ go vet ./errors/...
(clean)

$ go build ./errors/...
(clean)

Notes

The github.com/luxfi/node/errors package shipped with zero tests despite
being a public utility surface (sentinel errors, WrappedError context
chain, Multi/Join aggregation, retry helpers). This adds 22 tests covering:

- WrappedError.Error format (with and without message)
- Wrap/WrapWithContext nil pass-through and context preservation
- errors.Is / errors.As chain through Wrap (incl. double-wrap)
- IsNotFound, IsClosed, IsTimeout helpers
- IsTemporary against both sentinel errors and the Temporary() interface
- IsPermanent across all permanent sentinels + fmt.Errorf %w chains
- GetCategory: wrapped category, sentinel inference, unknown fallback,
  and the precedence rule (wrapped category beats inferred category)
- Multi.Error/Add/Err for 0, 1, and N errors; nil-add ignored
- Join nil pass-through and multi-error combination

Result: 100.0% statement coverage, race-clean.
@abhicris abhicris requested a review from hanzo-dev as a code owner June 1, 2026 12:09
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