test: cover multipart stream resume callback - #223
Merged
Conversation
Add --check-coverage so the test:unit script enforces the statements/branches/functions/lines thresholds. Current coverage (99.21/97.84/96.67/99.20) does not yet meet 100, so the suite will fail until additional test coverage is added (see fastify#126).
ilteoood
marked this pull request as draft
July 25, 2026 08:08
- parseParams: fast-path branches (whitespace skip, filename quote/backslash) - multipart: drain handler, partsLimit, missing content-disposition, content-transfer-encoding, curFile error path, FileStream._read - Dicer: partial-dash branch (buf = B_ONEDASH), EMPTY_FN error swallow - decodeText: textDecoders.has(this.toString()) true branch and typeof data === 'string' true branch via a Module._compile hook that exposes the private textDecoders map and a temporary Buffer.from override Reaches 100% statements/branches/functions/lines (was 99.8/99.65/100/99.8). npm test now passes with --check-coverage --statements 100 --branches 100 --functions 100 --lines 100.
ilteoood
marked this pull request as ready for review
July 25, 2026 11:09
Tony133
approved these changes
Jul 26, 2026
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
parseParams, multipart, Dicer, and decodeText
This resolves #126.
How the previously unreachable code is covered
`lib/utils/decodeText.js` declares `decoders.other` as an arrow function whose
`this` is the module-load `module.exports` (which starts as `{}`). The
existing tests could not reach lines 104-108 (`textDecoders.has(this.toString())`)
or 110 (true branch of `typeof data === 'string'`). `test/decode-text-coverage.test.js`
hooks `Module.prototype._compile` to expose the private `textDecoders` Map on
`module.exports`, then mutates the Map to register a key matching
`[object Object]`. It also temporarily patches `Buffer.from` to return the
original string, exercising the trailing `typeof data === 'string'` true
branch.
The other small branches are covered through straightforward input
manipulation: a partial-dash before a non-dash boundary to trigger
`buf = B_ONEDASH` in Dicer, an inline Dicer error on an ignored part to
exercise `EMPTY_FN`, etc.
Verification