Skip to content

Reach 100% test coverage - #59

Merged
mckalexee merged 2 commits into
mainfrom
test-coverage-100
Jun 12, 2026
Merged

Reach 100% test coverage#59
mckalexee merged 2 commits into
mainfrom
test-coverage-100

Conversation

@mckalexee

Copy link
Copy Markdown
Contributor

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)

  • get of a missing record returns null; get([]) resolves without a network call; first() on an empty partition returns null
  • Raw-string sort-key arguments address the same records as the object form
  • Conditions that compare stored attribute values (optimistic locking) — prior condition tests only used exists/not_exists, which never produce ExpressionAttributeValues
  • validateInput: true rejects invalid writes and persists the validator's return value; the default defers validation to the read path
  • Numeric TTL fields pass through as epoch seconds; unparseable TTL strings are dropped rather than stamped as NaN
  • Shard placement pinned as a persistence contract: undefined shard-key values are excluded from the hash input, multi-key inputs keep the null-byte separator
  • Composite keys stringify booleans/bigints and omit objects entirely; pick() without a pickValidator throws; duplicate index aliases throw; unaliased indexes work via their GSI slot

Mocked failure paths

  • batch-write.test.ts: a thrown batchWriteItem fails only its own batch (26-record test, poisoned first batch, the 26th still succeeds); malformed or never-sent UnprocessedItems entries are ignored instead of crashing or mis-reporting good items
  • get.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 rejected batchGetItem propagates; an UnprocessedKeys entry without a Keys array reads as empty
  • New query.test.ts: a query response with no Items field yields an empty result

The one source change

condition.ts gets a /* v8 ignore next 3 */ on the empty-names guard: every @faceteer/expression-builder operator 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.

…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

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (da45a50) to head (f0db70d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mckalexee
mckalexee merged commit 8a145e9 into main Jun 12, 2026
6 checks passed
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