Repository navigation
test(repositories): add unit tests for the notification outbox, delivery log and nip05 verification repositories - #918
Conversation
…ery log and nip05 verification repositories Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
🦋 Changeset detectedLatest commit: cc23343 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
[Low impact] The PR appears safe to merge; no blocking issues were found.
|
Coverage Report for CI Build 40101217063Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Warning No base build found for commit Coverage: 76.379%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
…he last_checked_at fallback Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
Description
Adds unit specs for the three repositories that had none:
notification-outbox,notification-delivery-logandnip05-verification. No production code changes.They run the repositories' real knex queries on the postgres dialect through a small recording client (
test/unit/repositories/recording-knex.ts) that never connects: each statement and its bindings are recorded and answered with scripted rows or counts, so the specs assert on the SQL that would run, not on stubbed repository methods.enqueue(pending, due now, unattempted),claimBatch(due pending plus processing rows whose 5 minute lease ran out, oldest first,for update skip locked, claimed rows marked processing),markDelivered,markFailed(back to pending with exponential backoff capped at a minute, dead once attempts are used up, error truncated to 2000 characters),deleteTerminalOlderThan(delivered and dead only).appendfor success, failure and test notifications,findSuccessfulTargetIds(successes only, so a retry skips delivered targets),findRecent(default limit and each filter),deleteOlderThan.findByPubkey,upsert(what is updated on conflict),findPendingVerifications,deleteByPubkey, andlistForAdmin(each filter, stale and fresh, the filters combined, count and page filtered alike, pagination).Related Issue
Closes #905
Motivation and Context
The notification outbox service spec stubs its repository, so the SQL of the repository was never run by a test, and
listForAdminalready serves the admin API untested.claimBatchis asserted on its query (locking and skipping locked rows); that two workers never receive the same message is guaranteed by PostgreSQL, so it is not something a unit test can show.How Has This Been Tested?
skipLocked, changing the backoff cap or the dead threshold, dropping the success filter, the null check of the stale filter or the clone of the count query each make a spec fail.pnpm lint,pnpm check:deps,pnpm run build:check,pnpm run test:unit.Screenshots (if appropriate):
Types of changes
Checklist: