Reach 100% test coverage - #59
Merged
Merged
Conversation
…lines Pin previously untested contracts through the public API: - batch put/delete: a thrown batchWriteItem fails only its own batch; malformed or unknown UnprocessedItems entries are ignored - batch get: unprocessed keys are retried, best-effort after 10 attempts, errors propagate, absent Keys arrays read as empty - validateInput: on-write validation uses the validator's return value; default defers validation to the read path - TTL: numeric fields pass through as epoch seconds; unparseable strings are not stamped as NaN - shard hashing: undefined shard keys are excluded from the hash input; placement is pinned as a persistence contract - composite keys: booleans/bigints stringify, objects are omitted - conditions comparing stored attribute values (optimistic locking) - raw-string sort-key arguments, empty-batch get, missing-record get, first() on an empty partition, unaliased and duplicate-alias indexes - query responses without an Items array yield an empty result lib/condition.ts gains a v8 ignore hint on the empty-names guard, which is unreachable (expression-builder always aliases at least one attribute name) but kept as defense against empty maps.
The repo gitignores package-lock.json, so CI's fresh npm install picked up typescript-eslint 8.61.0, whose no-unnecessary-type-assertion rule now flags three assertions in lib/facet.ts that TypeScript 6.0.3 no longer needs. Pre-existing on main; surfaced here because this was the first CI run since the rule update.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
============================================
+ Coverage 87.52% 100.00% +12.47%
============================================
Files 13 13
Lines 465 457 -8
Branches 92 91 -1
============================================
+ Hits 407 457 +50
+ Misses 32 0 -32
+ Partials 26 0 -26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Raises coverage from 93% statements / 81% branches to 100% on all four metrics (statements, branches, functions, lines). 24 new tests, 109 total. Test-only apart from a comment in
lib/condition.ts; no runtime behavior changes and no version bump — this rides along with the next release.Each test pins an observable contract through the public API rather than targeting lines:
Integration tests (
facet.test.ts, against DynamoDB Local)getof a missing record returnsnull;get([])resolves without a network call;first()on an empty partition returnsnullexists/not_exists, which never produceExpressionAttributeValuesvalidateInput: truerejects invalid writes and persists the validator's return value; the default defers validation to the read pathNaNpick()without apickValidatorthrows; duplicate index aliases throw; unaliased indexes work via their GSI slotMocked failure paths
batch-write.test.ts: a thrownbatchWriteItemfails only its own batch (26-record test, poisoned first batch, the 26th still succeeds); malformed or never-sentUnprocessedItemsentries are ignored instead of crashing or mis-reporting good itemsget.test.ts: unprocessed keys are retried (only the unprocessed key is re-requested), persistent unprocessed keys keep retrying, and after 10 attempts the get returns best-effort results (fake timers — the real backoff sums to ~20s); a rejectedbatchGetItempropagates; anUnprocessedKeysentry without aKeysarray reads as emptyquery.test.ts: a query response with noItemsfield yields an empty resultThe one source change
condition.tsgets a/* v8 ignore next 3 */on the empty-names guard: every@faceteer/expression-builderoperator aliases at least one attribute name, so the branch is unreachable, but the guard stays as defense against empty maps (which DynamoDB rejects).No coverage thresholds were added to the vitest config — CI does not gate on coverage.